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


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

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


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

示例1: graph

/*! \brief Add a Graph to the current Plotter
    \param index the index of the graph
    \param title the title of the graph
    \param color the color of the graph
    \param type the type of the graph (bar, lines, points)
    \param the tickness of the graph
    \param graph_y_scale to multiply the all data points for a scale factor
*/
Graph * Plotter::addGraph(QString remotePort,QString localPort,int index, QString title, QString color, QString type, int size, double graph_y_scale)
{
    Graph *graph = NULL;
    graph = new Graph(index,title,color,type,size,graph_y_scale,this->size);


    for(int i=0;i<graphList.count();i++) {
        Graph *g = (Graph *)graphList.at(i);
        Connection *con = g->getConnetion();
        if(!con){
            continue;
        }
        if(con->remotePortName == remotePort && con->localPortName == localPort){
            graph->curr_connection = g->curr_connection;
            graph->deleteConnection = false;
            break;
        }
    }
    graphList.append(graph);


    QCPGraph *customGraph = customPlot.addGraph(); // line
    customGraph->setPen(QPen(QColor(color),size));
    customGraph->setAntialiased(false);
    customGraph->setLineStyle(QCPGraph::lsLine);

    if(type == "points"){
        customGraph->setLineStyle(QCPGraph::lsNone);
        customGraph->setScatterStyle(QCPScatterStyle::ssDot);
    }

    if(type == "bars"){
        customGraph->setLineStyle(QCPGraph::lsImpulse);
        customGraph->setScatterStyle(QCPScatterStyle::ssNone);
    }


    QCPGraph *customGraphPoint = customPlot.addGraph(); // dot
    customGraphPoint->setPen(QPen(QColor(color)));
    customGraphPoint->setLineStyle(QCPGraph::lsNone);
    customGraphPoint->setScatterStyle(QCPScatterStyle::ssDisc);

    graph->setCustomGraph(customGraph);
    graph->setCustomGraphPoint(customGraphPoint);
    customPlot.replot();


    return graph;
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:57,代码来源:plotter.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: 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

示例4: 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

示例5: setData

void ScatterWidget::setData(const std::vector<PointD> &data, string legend)
{
    QCPGraph *graph = NULL;
    int nG = ui->scatter->graphCount();
    for(int i=0; i<nG; i++)
    {
        if(ui->scatter->graph(i)->name() == QString::fromStdString(legend))
        {
            graph = ui->scatter->graph(i);
            break;
        }
    }

    if(!graph)
    {
        graph = ui->scatter->addGraph();
        // ----------------------- Scatter Configuration ---------------------------
        graph->setName(QString::fromStdString(legend));
        QColor color_ = colorManager.getNewDifferentColor();
        graph->setPen(QPen(color_));
        graph->setLineStyle(QCPGraph::lsNone);
        graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssPlusCircle, 4));
        ui->scatter->legend->setVisible(true);
    }

    double min_x =  INFINITY, min_y =  INFINITY;
    double max_x = -INFINITY, max_y = -INFINITY;

    QVector<QCPGraphData> q_data(data.size());
    for(unsigned int i=0; i<data.size(); i++)
    {
        q_data[i] = QCPGraphData(data[i].x, data[i].y);

        if(ui->recButton->isChecked())
        {
            vector<double> vec2_double(2);
            vec2_double[0] = data[i].x;
            vec2_double[1] = data[i].y;
            vector<string> vec2_string(2);
            vec2_string[0] = legend + "_x";
            vec2_string[1] = legend + "_y";
            logger.addLogCsv(graph->dataCount(), vec2_string, vec2_double);
        }

        max_x = qMax(data[i].x, ui->scatter->xAxis->range().upper);
        min_x = qMin(data[i].x, ui->scatter->xAxis->range().lower);
        max_y = qMax(data[i].y, ui->scatter->yAxis->range().upper);
        min_y = qMin(data[i].y, ui->scatter->yAxis->range().lower);
    }

    graph->data()->set(q_data);
    ui->scatter->xAxis->setRange(min_x, max_x);
    ui->scatter->yAxis->setRange(min_y, max_y);
    ui->scatter->replot();
}
开发者ID:amiryanj,项目名称:smart-debug,代码行数:55,代码来源:scatterwidget.cpp

示例6: 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

示例7: 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

示例8: updateChannel

void RealTimePlot::updateChannel(int index)
{
    Channel *chan = channels[index];

    // Get parameters from channel
    QCPGraph *line = chan->getPtrGraphLine();
    QCPGraph *marker = chan->getPtrGraphMarker();
    QColor color = chan->getGraphColor();

    // Set parameters of line graph
    line->setPen(QPen(color));
    line->setLineStyle(QCPGraph::lsLine);
    line->setVisible(chan->getVisible(LINE));

    // Set parameters of marker graph
    marker->setName(chan->getName());
    marker->setPen(QPen(color));
    marker->setLineStyle(QCPGraph::lsNone);
    marker->setScatterStyle(chan->getMarkerStyle());
    marker->setVisible(chan->getVisible(MARKER));
}
开发者ID:kleinp,项目名称:RealTimePlot,代码行数:21,代码来源:realtimeplot.cpp

示例9: addPacket

void ScatterWidget::addPacket(const ScatterPacket &packet)
{
    QCPGraph *graph = NULL;
    int nG = ui->scatter->graphCount();
    for(int i=0; i<nG; i++)
    {
        if(ui->scatter->graph(i)->name() == QString::fromStdString(packet.legend))
        {
            graph = ui->scatter->graph(i);
            break;
        }
    }

    if(!graph)
    {
        graph = ui->scatter->addGraph();
        // ----------------------- Scatter Configuration ---------------------------
        graph->setName(QString::fromStdString(packet.legend));
        QColor color_ = colorManager.getNewDifferentColor();
        graph->setPen(QPen(color_));
        graph->setLineStyle(QCPGraph::lsNone);
        graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssPlusCircle, 4));
        ui->scatter->legend->setVisible(true);
    }

    graph->addData(packet.point.x, packet.point.y);
    //if(packet.point.x > ui->scatter->xAxis->max)

    double max_x = qMax(packet.point.x, ui->scatter->xAxis->range().upper);
    double min_x = qMin(packet.point.x, ui->scatter->xAxis->range().lower);
    double max_y = qMax(packet.point.y, ui->scatter->yAxis->range().upper);
    double min_y = qMin(packet.point.y, ui->scatter->yAxis->range().lower);

    ui->scatter->xAxis->setRange(min_x, max_x);
    ui->scatter->yAxis->setRange(min_y, max_y);

    if(realTimePlot)
        ui->scatter->replot();
    else
        ui->scatter->replot(QCustomPlot::rpQueuedReplot);

    if(ui->recButton->isChecked())
    {
        vector<double> vec2_double(2);
        vec2_double[0] = packet.point.x;
        vec2_double[1] = packet.point.y;
        vector<string> vec2_string(2);
        vec2_string[0] = packet.legend + "_x";
        vec2_string[1] = packet.legend + "_y";
        logger.addLogCsv(graph->dataCount(), vec2_string, vec2_double);
    }
}
开发者ID:amiryanj,项目名称:smart-debug,代码行数:52,代码来源:scatterwidget.cpp

示例10: createGraph

	QCPGraph* SensorDashboard::createGraph(const QString& name, const QColor& color)
	{
		QPen pen;
		pen.setBrush(color);

		QCPGraph *graph = mPlot->addGraph();
		graph->setName(name);
		graph->setLineStyle(QCPGraph::lsLine);
		graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone));
		graph->setPen(pen);

		return graph;
	}
开发者ID:cglogic,项目名称:vikki,代码行数:13,代码来源:sensor_dashboard.cpp

示例11: 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

示例12: 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

示例13: 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

示例14: createNewPlot

  void DataBrokerPlotter::createNewPlot() {
    char text[50];
    // create first curve
    std::string cfgName = name;
    std::string tmpString;
    Plot *newPlot = new Plot;
    QCPGraph *newCurve = qcPlot->addGraph();

    newCurve->setAntialiasedFill(false);

    newPlot->dpId = nextPlotId++;
    sprintf(text, "graph%02d", newPlot->dpId);
    newPlot->name = std::string(text);

    cfgName.append("/");
    cfgName.append(newPlot->name);
    cfgName.append("/");

    newCurve->setPen( QPen(colors[(newPlot->dpId-1) % 8], 0.5) );
    newCurve->setLineStyle( QCPGraph::lsLine );

    newPlot->curve = newCurve;
    
    plots.push_back(newPlot);

    // add datapackage for first plot
    mars::data_broker::DataPackage dbPackageX;// = new mars::data_broker::DataPackage;
    mars::data_broker::DataPackage dbPackageY;// = new mars::data_broker::DataPackage;
    dbPackageX.add("xvalue", (double)0.0);
    dbPackageY.add("yvalue", (double)0.0);
    //dbPackage->add("yvalue", (double)0.0);

    tmpString = name;
    tmpString.append("/");
    tmpString.append(text);
    tmpString.append("/xvalue");
    dataBroker->pushData("data_broker_plotter", tmpString,
                         dbPackageX, this,
                         mars::data_broker::DATA_PACKAGE_READ_WRITE_FLAG);
    dataBroker->registerSyncReceiver(this, "data_broker_plotter",
                                     tmpString, newPlot->dpId*10);
    tmpString = name;
    tmpString.append("/");
    tmpString.append(text);
    tmpString.append("/yvalue");
    dataBroker->pushData("data_broker_plotter", tmpString,
                         dbPackageY, this,
                         mars::data_broker::DATA_PACKAGE_READ_WRITE_FLAG);
    dataBroker->registerSyncReceiver(this, "data_broker_plotter",
                                     tmpString, newPlot->dpId*10+1);
    newPlot->gotData = 0;
    
    tmpString = cfgName;
    tmpString.append("sTime");
    newPlot->sTime = cfg->getOrCreateProperty("DataBrokerPlotter",
                                              tmpString.c_str(),
                                              (double)0.0, this);
    tmpString = cfgName;
    tmpString.append("xRange");
    newPlot->xRange = cfg->getOrCreateProperty("DataBrokerPlotter",
                                               tmpString.c_str(),
                                               (double)0.0, this);
    tmpString = cfgName;
    tmpString.append("yScale");
    newPlot->yScale = cfg->getOrCreateProperty("DataBrokerPlotter",
                                               tmpString.c_str(),
                                               (double)1.0, this);
    tmpString = cfgName;
    tmpString.append("yOffset");
    newPlot->yOffset = cfg->getOrCreateProperty("DataBrokerPlotter",
                                                tmpString.c_str(),
                                                (double)0.0, this);

    cfgParamIdToPlot[newPlot->sTime.paramId] = newPlot;
    cfgParamIdToPlot[newPlot->xRange.paramId] = newPlot;
    cfgParamIdToPlot[newPlot->yScale.paramId] = newPlot;
    cfgParamIdToPlot[newPlot->yOffset.paramId] = newPlot;
    newPlot->cfgParamIdProp[newPlot->sTime.paramId] = &newPlot->sTime;
    newPlot->cfgParamIdProp[newPlot->xRange.paramId] = &newPlot->xRange;
    newPlot->cfgParamIdProp[newPlot->yScale.paramId] = &newPlot->yScale;
    newPlot->cfgParamIdProp[newPlot->yOffset.paramId] = &newPlot->yOffset;
  }
开发者ID:EwaldHartmann,项目名称:mars,代码行数:82,代码来源:DataBrokerPlotter.cpp

示例15: updatePlot


//.........这里部分代码省略.........
        field = Global::getInstance()->getExtraField(2);
        ui->customPlot->yAxis->setLabel(field.axisLabel);
        break;
    case(FIELD4):
        field = Global::getInstance()->getExtraField(3);
        ui->customPlot->yAxis->setLabel(field.axisLabel);
        break;
    default:
        assert(false);
        break;
    }

    //
    bool buildGlobalPlot = (selectionGraph->isEmpty());

    set<Group> groups;
    map<Group,vector<SelectionGraphNode*> > mapGroupToNodes;
    map<Group,vector<SelectionGraphEdge*> > mapGroupToEdges;
    set<Group>::iterator groupIterator;
    selectionGraph->groupNodesAndEdgeByColor(groups,mapGroupToNodes,mapGroupToEdges);
    map<Group,QCPGraph*> mapGroupGraph;

    //
    set<Group> notEmptyGroups;
    map<Group,vector<SelectionGraphNode*> > tempMapGroupToNodes;

    if(buildGlobalPlot){
        QPen pen;
        QCPGraph* graph = ui->customPlot->addGraph();
        QColor color(0,0,0);
        mapGroupGraph[Group(color)] = graph;
        color.setAlphaF(0.05);
        pen.setColor(color);
        graph->setPen(pen);
        graph->setLineStyle(QCPGraph::lsNone);
        graph->setScatterStyle(QCP::ssDisc);
        graph->setScatterSize(10);
    }
    else{
        //
        for(groupIterator = groups.begin() ; groupIterator != groups.end() ; ++groupIterator){
            vector<SelectionGraphNode*> &groupNodes = mapGroupToNodes[*groupIterator];
            vector<SelectionGraphNode*> validGroupNodes;
            int numGroupNodes = groupNodes.size();

            for(int i = 0 ; i < numGroupNodes ; ++i){
                SelectionGraphNode* node = groupNodes.at(i);
                if(node->inDegree() + node->outDegree() == 0)
                    validGroupNodes.push_back(node);
            }

            vector<SelectionGraphEdge*> &groupEdges = mapGroupToEdges[*groupIterator];
            if(groupEdges.size() + validGroupNodes.size() > 0){
                notEmptyGroups.insert(*groupIterator);
                tempMapGroupToNodes[*groupIterator] = validGroupNodes;
            }
        }

        groups.clear();
        groups = notEmptyGroups;
        mapGroupToNodes.clear();
        mapGroupToNodes = tempMapGroupToNodes;

        //
        for(groupIterator = groups.begin() ; groupIterator != groups.end() ; ++groupIterator){
            QPen pen;
开发者ID:Rambo2015,项目名称:TaxiVis,代码行数:67,代码来源:scatterplotwidget.cpp


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