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


C++ QCustomPlot::addPlottable方法代码示例

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


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

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

示例2: plotHistogram

void Window::plotHistogram(QVector<double> key, QVector<double> nonEq, QVector<double> eqValue, QVector<double> lutValue)
{
    QCustomPlot *histogramPlot = ui->histogramPlot;

    histogramPlot->clearGraphs();

    // Non Equalized
    QCPBars *nonEqHistBars = new QCPBars(histogramPlot->xAxis, histogramPlot->yAxis);
    histogramPlot->addPlottable(nonEqHistBars);
    nonEqHistBars->setWidth(1);
    nonEqHistBars->setData(key, nonEq);
    nonEqHistBars->setPen(Qt::NoPen);
    nonEqHistBars->setBrush(QColor(10, 140, 70, 160));

    //    // Equalized
    //    QCPBars *eqHistBars = new QCPBars(histogramPlot->xAxis, histogramPlot->yAxis);
    //    histogramPlot->addPlottable(eqHistBars);
    //    eqHistBars->setWidth(1);
    //    eqHistBars->setData(key, eqValue);
    //    eqHistBars->setPen(Qt::NoPen);
    //    eqHistBars->setBrush(QColor(10, 100, 50, 70));
    ////    eqHistBars->moveAbove(eqHistBars);

    //    // LUT
    //    QCPGraph *lut = histogramPlot->addGraph();
    //    lut->setData(key, lutValue);
    //    lut->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssNone, QPen(Qt::black, 1.5), QBrush(Qt::white), 9));
    //    lut->setLineStyle(QCPGraph::lsStepCenter);
    //    lut->setPen(QPen(QColor(120, 120, 120), 2));

    histogramPlot->replot();
    histogramPlot->rescaleAxes();


}
开发者ID:walternestor,项目名称:Volume_Rendering_Using_GLSL,代码行数:35,代码来源:window.cpp

示例3: update

bool BarGraph::update(const GRT::VectorDouble &sample ) {

    if( !initialized ) return false;

    this->data = sample;

    //If the plot is hidden then there is no point in updating the graph
    if( this->isHidden() ) {
        return true;
    }

    QCustomPlot *plot = ui->graph;
    QVector<double> keyData;
    QVector<double> valueData;
    QVector<double> tickVector;
    QVector<QString> tickLabels;
    const unsigned int K = (unsigned int)data.size();

    plot->clearPlottables();

    QCPBars *bar = new QCPBars(plot->xAxis,plot->yAxis);
    plot->addPlottable( bar );

    //Add the data to the graph
    for(unsigned int k=0; k<K; k++) {
        keyData << k+1;
        valueData << data[k];
    }
    bar->setData(keyData, valueData);

    //Add the tick labels
    for(unsigned int k=0; k<K; k++) {
        tickVector << double(k+1);
        tickLabels << QString::fromStdString( GRT::Util::intToString( k+1 ) );
    }
    plot->xAxis->setAutoTicks(false);
    plot->xAxis->setAutoTickLabels(false);
    plot->xAxis->setTickVector( tickVector );
    plot->xAxis->setTickVectorLabels( tickLabels );
    plot->xAxis->setLabel("Features");
    plot->yAxis->setLabel("Values");

    plot->rescaleAxes();
    plot->replot();

    return true;
}
开发者ID:GaoXiaojian,项目名称:grt,代码行数:47,代码来源:bargraph.cpp

示例4: createChart

QCustomPlot* Plots::createChart(QVector<double> x, QVector<double> y, QString chartName)
{
    QCustomPlot* customPlot = new QCustomPlot();
    // create and configure plottables:

    QCPBars *bars1 = new QCPBars(customPlot->xAxis, customPlot->yAxis);
    customPlot->addPlottable(bars1);
    bars1->setWidth(0.3);
    bars1->setData(x, y);
    bars1->setPen(QPen(Qt::red));
    bars1->setBrush(QColor(10, 140, 70, 160));
    // set title of plot:
    customPlot->plotLayout()->insertRow(0);
    customPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(customPlot, chartName));
    // set a fixed tick-step to one tick per year value:
    customPlot->xAxis->setAutoTickStep(false);
    customPlot->xAxis->setTickStep(1);
    customPlot->xAxis->setSubTickCount(3);
    // set a fixed tick-step to one tick per колво value:
    customPlot->yAxis->setAutoTickStep(false);
    customPlot->yAxis->setTickStep(10);
    customPlot->yAxis->setSubTickCount(3);
    // labels
    customPlot->xAxis->setLabel("Год");
    customPlot->yAxis->setLabel("% человек");
    customPlot->yAxis->setLabelColor(Qt::white);
    customPlot->xAxis->setLabelColor(Qt::white);
    // move bars above graphs and grid below bars:
    customPlot->addLayer("abovemain", customPlot->layer("main"), QCustomPlot::limAbove);
    customPlot->addLayer("belowmain", customPlot->layer("main"), QCustomPlot::limBelow);
    bars1->setLayer("abovemain");
    customPlot->xAxis->grid()->setLayer("belowmain");
    customPlot->yAxis->grid()->setLayer("belowmain");
    // set some pens, brushes and backgrounds:
    customPlot->xAxis->setBasePen(QPen(Qt::white, 1));
    customPlot->yAxis->setBasePen(QPen(Qt::white, 1));
    customPlot->xAxis->setTickPen(QPen(Qt::white, 1));
    customPlot->yAxis->setTickPen(QPen(Qt::white, 1));
    customPlot->xAxis->setSubTickPen(QPen(Qt::white, 1));
    customPlot->yAxis->setSubTickPen(QPen(Qt::white, 1));
    customPlot->xAxis->setTickLabelColor(Qt::white);
    customPlot->yAxis->setTickLabelColor(Qt::white);
    customPlot->xAxis->grid()->setPen(QPen(QColor(140, 140, 140), 1, Qt::DotLine));
    customPlot->yAxis->grid()->setPen(QPen(QColor(140, 140, 140), 1, Qt::DotLine));
    customPlot->xAxis->grid()->setSubGridPen(QPen(QColor(80, 80, 80), 1, Qt::DotLine));
    customPlot->yAxis->grid()->setSubGridPen(QPen(QColor(80, 80, 80), 1, Qt::DotLine));
    customPlot->xAxis->grid()->setSubGridVisible(true);
    customPlot->yAxis->grid()->setSubGridVisible(true);
    customPlot->xAxis->grid()->setZeroLinePen(Qt::NoPen);
    customPlot->yAxis->grid()->setZeroLinePen(Qt::NoPen);
    customPlot->xAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
    customPlot->yAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
    QLinearGradient plotGradient;
    plotGradient.setStart(0, 0);
    plotGradient.setFinalStop(0, 350);
    plotGradient.setColorAt(0, QColor(80, 80, 80));
    plotGradient.setColorAt(1, QColor(50, 50, 50));
    customPlot->setBackground(plotGradient);
    QLinearGradient axisRectGradient;
    axisRectGradient.setStart(0, 0);
    axisRectGradient.setFinalStop(0, 350);
    axisRectGradient.setColorAt(0, QColor(80, 80, 80));
    axisRectGradient.setColorAt(1, QColor(30, 30, 30));
    customPlot->axisRect()->setBackground(axisRectGradient);
    customPlot->rescaleAxes();
    customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
    return customPlot;
}
开发者ID:kanbodows,项目名称:kafpocs,代码行数:68,代码来源:plots.cpp

示例5: WiresharkDialog

SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, seq_analysis_info_t *sainfo) :
    WiresharkDialog(parent, cf),
    ui(new Ui::SequenceDialog),
    sainfo_(sainfo),
    num_items_(0),
    packet_num_(0),
    node_label_w_(20)
{
    ui->setupUi(this);
    QCustomPlot *sp = ui->sequencePlot;
    setWindowSubtitle(sainfo ? tr("Call Flow") : tr("Flow"));

    if (!sainfo_) {
        sainfo_ = sequence_analysis_info_new();
        sainfo_->type = SEQ_ANALYSIS_ANY;
        sainfo_->all_packets = TRUE;
    } else {
        num_items_ = sequence_analysis_get_nodes(sainfo_);
    }

    seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2);
    sp->addPlottable(seq_diagram_);
    sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis);

    sp->xAxis->setVisible(false);
    sp->xAxis->setPadding(0);
    sp->xAxis->setLabelPadding(0);
    sp->xAxis->setTickLabelPadding(0);
    sp->xAxis2->setVisible(true);
    sp->yAxis2->setVisible(true);

    one_em_ = QFontMetrics(sp->yAxis->labelFont()).height();
    ui->horizontalScrollBar->setSingleStep(100 / one_em_);
    ui->verticalScrollBar->setSingleStep(100 / one_em_);

    sp->setInteractions(QCP::iRangeDrag);

    ui->gridLayout->setSpacing(0);
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange)));

    ctx_menu_.addAction(ui->actionReset);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionMoveRight10);
    ctx_menu_.addAction(ui->actionMoveLeft10);
    ctx_menu_.addAction(ui->actionMoveUp10);
    ctx_menu_.addAction(ui->actionMoveDown10);
    ctx_menu_.addAction(ui->actionMoveRight1);
    ctx_menu_.addAction(ui->actionMoveLeft1);
    ctx_menu_.addAction(ui->actionMoveUp1);
    ctx_menu_.addAction(ui->actionMoveDown1);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionGoToPacket);

    ui->showComboBox->blockSignals(true);
    ui->showComboBox->setCurrentIndex(0);
    ui->showComboBox->blockSignals(false);
    ui->addressComboBox->blockSignals(true);
    ui->addressComboBox->setCurrentIndex(0);
    ui->addressComboBox->blockSignals(false);

    QComboBox *fcb = ui->flowComboBox;
    fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY);
    fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP);

    ui->flowComboBox->blockSignals(true);
    ui->flowComboBox->setCurrentIndex(sainfo_->type);

    if (sainfo_->type == SEQ_ANALYSIS_VOIP) {
        ui->controlFrame->hide();
    } else {
        ui->flowComboBox->blockSignals(false);
    }

    QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save);
    save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS));

    // XXX Use recent settings instead
    resize(parent.width(), parent.height() * 4 / 5);

    connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int)));
    connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int)));
    connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange)));
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange)));
    connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*)));
    connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*)));
    connect(sp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*)));
    connect(this, SIGNAL(goToPacket(int)), seq_diagram_, SLOT(setSelectedPacket(int)));

    disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));

    fillDiagram();
}
开发者ID:JunichiWatanuki,项目名称:wireshark,代码行数:92,代码来源:sequence_dialog.cpp

示例6: QDialog

SequenceDialog::SequenceDialog(QWidget *parent, capture_file *cf, SequenceType type) :
    QDialog(parent),
    ui(new Ui::SequenceDialog),
    cap_file_(cf),
    num_items_(0),
    packet_num_(0),
    node_label_w_(20)
{
    ui->setupUi(this);
    QCustomPlot *sp = ui->sequencePlot;

    seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2);
    sp->addPlottable(seq_diagram_);
    sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis);

    sp->xAxis->setVisible(false);
    sp->xAxis->setPadding(0);
    sp->xAxis->setLabelPadding(0);
    sp->xAxis->setTickLabelPadding(0);
    sp->xAxis2->setVisible(true);
    sp->yAxis2->setVisible(true);

    one_em_ = QFontMetrics(sp->yAxis->labelFont()).height();
    ui->horizontalScrollBar->setSingleStep(100 / one_em_);
    ui->verticalScrollBar->setSingleStep(100 / one_em_);

    sp->setInteractions(QCP::iRangeDrag);

    ui->gridLayout->setSpacing(0);
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange)));

    ctx_menu_.addAction(ui->actionReset);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionMoveRight10);
    ctx_menu_.addAction(ui->actionMoveLeft10);
    ctx_menu_.addAction(ui->actionMoveUp10);
    ctx_menu_.addAction(ui->actionMoveDown10);
    ctx_menu_.addAction(ui->actionMoveRight1);
    ctx_menu_.addAction(ui->actionMoveLeft1);
    ctx_menu_.addAction(ui->actionMoveUp1);
    ctx_menu_.addAction(ui->actionMoveDown1);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionGoToPacket);

    memset (&seq_analysis_, 0, sizeof(seq_analysis_));

    ui->showComboBox->blockSignals(true);
    ui->showComboBox->setCurrentIndex(0);
    ui->showComboBox->blockSignals(false);
    ui->addressComboBox->blockSignals(true);
    ui->addressComboBox->setCurrentIndex(0);
    ui->addressComboBox->blockSignals(false);

    QComboBox *fcb = ui->flowComboBox;
    fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY);
    fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP);

    ui->flowComboBox->blockSignals(true);
    switch (type) {
    case any:
        seq_analysis_.type = SEQ_ANALYSIS_ANY;
        ui->flowComboBox->setCurrentIndex(SEQ_ANALYSIS_ANY);
        break;
    case tcp:
        seq_analysis_.type = SEQ_ANALYSIS_TCP;
        ui->flowComboBox->setCurrentIndex(SEQ_ANALYSIS_TCP);
        break;
    case voip:
        seq_analysis_.type = SEQ_ANALYSIS_VOIP;
        ui->flowComboBox->hide();
        ui->flowLabel->hide();
        break;
    }
    ui->flowComboBox->blockSignals(false);
    seq_analysis_.all_packets = TRUE;

    QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save);
    save_bt->setText(tr("Save As..."));

    // XXX Use recent settings instead
    if (parent) {
        resize(parent->width(), parent->height() * 4 / 5);
    }

    connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int)));
    connect(ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int)));
    connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange)));
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange)));
    connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*)));
    connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*)));
    connect(sp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*)));
    connect(this, SIGNAL(goToPacket(int)), seq_diagram_, SLOT(setSelectedPacket(int)));

    disconnect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));

    fillDiagram();
}
开发者ID:dot-Sean,项目名称:wireshark-http2,代码行数:97,代码来源:sequence_dialog.cpp

示例7: repaintplot

void chartcreate::repaintplot()
{
    QCustomPlot * customPlot = ui->chart_preview;
    // create empty bar chart objects:

    QCPBars *regen = new QCPBars(customPlot->xAxis, customPlot->yAxis);
    QCPBars *nuclear = new QCPBars(customPlot->xAxis, customPlot->yAxis);
    QCPBars *fossil = new QCPBars(customPlot->xAxis, customPlot->yAxis);
    customPlot->addPlottable(regen);
    customPlot->addPlottable(nuclear);
    customPlot->addPlottable(fossil);
    // set names and colors:
    QPen pen;
    pen.setWidthF(1.2);
    fossil->setName("Danone");
    pen.setColor(QColor(255, 131, 0));
    fossil->setPen(pen);
    fossil->setBrush(QColor(255, 131, 0, 50));
    nuclear->setName("AuBonLait");
    pen.setColor(QColor(1, 92, 191));
    nuclear->setPen(pen);
    nuclear->setBrush(QColor(1, 92, 191, 50));
    regen->setName("Yoplait");
    pen.setColor(QColor(150, 222, 0));
    regen->setPen(pen);
    regen->setBrush(QColor(150, 222, 0, 70));
    // stack bars ontop of each other:
    nuclear->moveAbove(fossil);
    regen->moveAbove(nuclear);

    // prepare x axis with country labels:
    QVector<double> ticks;
    QVector<QString> labels;
    ticks << 1 << 2 ;
    labels << "Homme" << "Femme" ;
    customPlot->xAxis->setAutoTicks(false);
    customPlot->xAxis->setAutoTickLabels(false);
    customPlot->xAxis->setTickVector(ticks);
    customPlot->xAxis->setTickVectorLabels(labels);
    customPlot->xAxis->setTickLabelRotation(60);
    customPlot->xAxis->setSubTickCount(0);
    customPlot->xAxis->setTickLength(0, 4);
    customPlot->xAxis->grid()->setVisible(true);
    customPlot->xAxis->setRange(0, 8);

    // prepare y axis:
    customPlot->yAxis->setRange(0, 12.1);
    customPlot->yAxis->setPadding(5); // a bit more space to the left border
    customPlot->yAxis->setLabel("Marque de Yaourt Connu");
    customPlot->yAxis->grid()->setSubGridVisible(true);
    QPen gridPen;
    gridPen.setStyle(Qt::SolidLine);
    gridPen.setColor(QColor(0, 0, 0, 25));
    customPlot->yAxis->grid()->setPen(gridPen);
    gridPen.setStyle(Qt::DotLine);
    customPlot->yAxis->grid()->setSubGridPen(gridPen);

    // Add data:
    QVector<double> fossilData, nuclearData, regenData;
    fossilData  << 0.86*10.5 << 0.83*5.5;
    nuclearData << 0.08*10.5 << 0.12*5.5;
    regenData   << 0.06*10.5 << 0.05*5.5;
    fossil->setData(ticks, fossilData);
    nuclear->setData(ticks, nuclearData);
    regen->setData(ticks, regenData);

    // setup legend:
    customPlot->legend->setVisible(true);
    customPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignHCenter);
    customPlot->legend->setBrush(QColor(255, 255, 255, 200));
    QPen legendPen;
    legendPen.setColor(QColor(130, 130, 130, 200));
    customPlot->legend->setBorderPen(legendPen);
    QFont legendFont = font();
    legendFont.setPointSize(10);
    customPlot->legend->setFont(legendFont);
    customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
}
开发者ID:BnHrb,项目名称:beam-rainbow,代码行数:78,代码来源:chartcreate.cpp

示例8: base_pen

SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *info) :
    WiresharkDialog(parent, cf),
    ui(new Ui::SequenceDialog),
    info_(info),
    num_items_(0),
    packet_num_(0),
    sequence_w_(1)
{
    ui->setupUi(this);
    loadGeometry(parent.width(), parent.height() * 4 / 5);

    QCustomPlot *sp = ui->sequencePlot;
    setWindowSubtitle(info_ ? tr("Call Flow") : tr("Flow"));

    if (!info_) {
        info_ = new SequenceInfo(sequence_analysis_info_new());
        info_->sainfo()->type = SEQ_ANALYSIS_ANY;
        info_->sainfo()->all_packets = TRUE;
    } else {
        info_->ref();
        num_items_ = sequence_analysis_get_nodes(info_->sainfo());
    }

    seq_diagram_ = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2);
    sp->addPlottable(seq_diagram_);

    // When dragging is enabled it's easy to drag past the lower and upper
    // bounds of each axis. Disable it for now.
    //sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis);
    //sp->setInteractions(QCP::iRangeDrag);

    sp->xAxis->setVisible(false);
    sp->xAxis->setPadding(0);
    sp->xAxis->setLabelPadding(0);
    sp->xAxis->setTickLabelPadding(0);

    QPen base_pen(ColorUtils::alphaBlend(palette().text(), palette().base(), 0.25));
    base_pen.setWidthF(0.5);
    sp->xAxis2->setBasePen(base_pen);
    sp->yAxis->setBasePen(base_pen);
    sp->yAxis2->setBasePen(base_pen);

    sp->xAxis2->setVisible(true);
    sp->yAxis2->setVisible(true);

    key_text_ = new QCPItemText(sp);
    key_text_->setText(tr("Time"));
    sp->addItem(key_text_);

    key_text_->setPositionAlignment(Qt::AlignRight | Qt::AlignVCenter);
    key_text_->position->setType(QCPItemPosition::ptAbsolute);
    key_text_->setClipToAxisRect(false);

    comment_text_ = new QCPItemText(sp);
    comment_text_->setText(tr("Comment"));
    sp->addItem(comment_text_);

    comment_text_->setPositionAlignment(Qt::AlignLeft | Qt::AlignVCenter);
    comment_text_->position->setType(QCPItemPosition::ptAbsolute);
    comment_text_->setClipToAxisRect(false);

    one_em_ = QFontMetrics(sp->yAxis->labelFont()).height();
    ui->horizontalScrollBar->setSingleStep(100 / one_em_);
    ui->verticalScrollBar->setSingleStep(100 / one_em_);

    ui->gridLayout->setSpacing(0);
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange)));

    ctx_menu_.addAction(ui->actionReset);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionMoveRight10);
    ctx_menu_.addAction(ui->actionMoveLeft10);
    ctx_menu_.addAction(ui->actionMoveUp10);
    ctx_menu_.addAction(ui->actionMoveDown10);
    ctx_menu_.addAction(ui->actionMoveRight1);
    ctx_menu_.addAction(ui->actionMoveLeft1);
    ctx_menu_.addAction(ui->actionMoveUp1);
    ctx_menu_.addAction(ui->actionMoveDown1);
    ctx_menu_.addSeparator();
    ctx_menu_.addAction(ui->actionGoToPacket);
    ctx_menu_.addAction(ui->actionGoToNextPacket);
    ctx_menu_.addAction(ui->actionGoToPreviousPacket);

    ui->showComboBox->setCurrentIndex(0);
    ui->addressComboBox->setCurrentIndex(0);

    QComboBox *fcb = ui->flowComboBox;
    fcb->addItem(ui->actionFlowAny->text(), SEQ_ANALYSIS_ANY);
    fcb->addItem(ui->actionFlowTcp->text(), SEQ_ANALYSIS_TCP);

    ui->flowComboBox->setCurrentIndex(info_->sainfo()->type);

    if (info_->sainfo()->type == SEQ_ANALYSIS_VOIP) {
        ui->flowComboBox->blockSignals(true);
        ui->controlFrame->hide();
    }

    QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save);
    save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS));

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

示例9: QDialog

LBMUIMFlowDialog::LBMUIMFlowDialog(QWidget * parent, capture_file * cfile) :
    QDialog(parent),
    m_ui(new Ui::LBMUIMFlowDialog),
    m_capture_file(cfile),
    m_num_items(0),
    m_packet_num(0),
    m_node_label_width(20)
{
    m_ui->setupUi(this);
    QCustomPlot * sp = m_ui->sequencePlot;

    m_sequence_diagram = new SequenceDiagram(sp->yAxis, sp->xAxis2, sp->yAxis2);
    sp->addPlottable(m_sequence_diagram);
    sp->axisRect()->setRangeDragAxes(sp->xAxis2, sp->yAxis);

    sp->xAxis->setVisible(false);
    sp->xAxis->setPadding(0);
    sp->xAxis->setLabelPadding(0);
    sp->xAxis->setTickLabelPadding(0);
    sp->xAxis2->setVisible(true);
    sp->yAxis2->setVisible(true);

    m_one_em = QFontMetrics(sp->yAxis->labelFont()).height();
    m_ui->horizontalScrollBar->setSingleStep(100 / m_one_em);
    m_ui->verticalScrollBar->setSingleStep(100 / m_one_em);

    sp->setInteractions(QCP::iRangeDrag);

    m_ui->gridLayout->setSpacing(0);
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), sp->yAxis2, SLOT(setRange(QCPRange)));

    m_context_menu.addAction(m_ui->actionReset);
    m_context_menu.addSeparator();
    m_context_menu.addAction(m_ui->actionMoveRight10);
    m_context_menu.addAction(m_ui->actionMoveLeft10);
    m_context_menu.addAction(m_ui->actionMoveUp10);
    m_context_menu.addAction(m_ui->actionMoveDown10);
    m_context_menu.addAction(m_ui->actionMoveRight1);
    m_context_menu.addAction(m_ui->actionMoveLeft1);
    m_context_menu.addAction(m_ui->actionMoveUp1);
    m_context_menu.addAction(m_ui->actionMoveDown1);
    m_context_menu.addSeparator();
    m_context_menu.addAction(m_ui->actionGoToPacket);

    memset(&m_sequence_analysis, 0, sizeof(m_sequence_analysis));

    m_ui->showComboBox->blockSignals(true);
    m_ui->showComboBox->setCurrentIndex(0);
    m_ui->showComboBox->blockSignals(false);
    m_sequence_analysis.all_packets = TRUE;
    m_sequence_analysis.any_addr = TRUE;

    QPushButton * save_bt = m_ui->buttonBox->button(QDialogButtonBox::Save);
    save_bt->setText(tr("Save As" UTF8_HORIZONTAL_ELLIPSIS));

    // XXX Use recent settings instead
    if (parent)
    {
        resize(parent->width(), parent->height() * 4 / 5);
    }

    connect(m_ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(hScrollBarChanged(int)));
    connect(m_ui->verticalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(vScrollBarChanged(int)));
    connect(sp->xAxis2, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange)));
    connect(sp->yAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(yAxisChanged(QCPRange)));
    connect(sp, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(diagramClicked(QMouseEvent*)));
    connect(sp, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoved(QMouseEvent*)));
    connect(sp, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseReleased(QMouseEvent*)));
    connect(this, SIGNAL(goToPacket(int)), m_sequence_diagram, SLOT(setSelectedPacket(int)));

    disconnect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));

    fillDiagram();
}
开发者ID:appneta,项目名称:wireshark,代码行数:74,代码来源:lbm_uimflow_dialog.cpp

示例10: detachPlot

void YarrGui::detachPlot(){
    if(ui->plotTree->currentItem() == nullptr){
        std::cerr << "Please select plot to detach...\n";
        return;
    }
    if(ui->plotTree->currentItem()->childCount() > 0){
        std::cerr << "Please select plot to detach...\n";
        return;
    }

    PlotDialog * myPDiag = new PlotDialog();
    QCustomPlot * plotWidget = dynamic_cast<QCustomPlot*>(ui->scanPlots_tabWidget->currentWidget());
    if(plotWidget == nullptr){
        std::cerr << "Severe cast error. Aborting...\n";
        return;
    }

    QCustomPlot * transferPlot = dynamic_cast<QCustomPlot*>(myPDiag->childAt(10, 10));
    if(transferPlot == nullptr){
        std::cerr << "Severe cast error. Aborting...\n";
        return;
    }

    QCPPlotTitle * widgetPT = dynamic_cast<QCPPlotTitle*>(plotWidget->plotLayout()->element(0, 0));
    if(widgetPT == nullptr){
        std::cerr << "Severe cast error. Aborting... \n";
        return;
    }

    if(dynamic_cast<QCPColorMap*>(plotWidget->plottable(0)) != nullptr){
        QCPColorMap * widgetCMap = dynamic_cast<QCPColorMap*>(plotWidget->plottable(0));

        QCPColorScale * widgetCScale = dynamic_cast<QCPColorScale*>(plotWidget->plotLayout()->element(1, 1));
        if(widgetCScale == nullptr) {
            std::cerr << "Severe cast error. Aborting... \n";
            return;
        }

        transferPlot->plotLayout()->insertRow(0);
        transferPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(transferPlot, widgetPT->text()));

        QCPColorMap * transferCMap = new QCPColorMap(transferPlot->xAxis, transferPlot->yAxis);
        transferPlot->addPlottable(transferCMap);
        transferCMap->data()->setSize(80, 336);
        transferCMap->setData(widgetCMap->data(), true);
        QCPColorScale * transferCScale = new QCPColorScale(transferPlot);
        transferPlot->plotLayout()->addElement(1, 1, transferCScale);
        transferCScale->setType(QCPAxis::atRight);
        transferCMap->setColorScale(transferCScale);
        transferCMap->keyAxis()->setLabel(widgetCMap->keyAxis()->label());
        transferCMap->valueAxis()->setLabel(widgetCMap->valueAxis()->label());

        transferCScale->axis()->setLabel(widgetCScale->axis()->label());
        transferCMap->setGradient(QCPColorGradient::gpPolar);
        transferCMap->rescaleDataRange();
    }else if(dynamic_cast<QCPBars*>(plotWidget->plottable(0)) != nullptr){
        QCPBars * widgetBars = dynamic_cast<QCPBars*>(plotWidget->plottable(0));

        QCPBars * transferBars = new QCPBars(transferPlot->xAxis, transferPlot->yAxis);
        transferBars->setData(widgetBars->data(), true);
        transferBars->rescaleAxes();

        transferPlot->plotLayout()->insertRow(0);
        transferPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(transferPlot, widgetPT->text()));
        transferBars->keyAxis()->setLabel(widgetBars->keyAxis()->label());
        transferBars->valueAxis()->setLabel(widgetBars->valueAxis()->label());
    }else{
        std::cerr << "Severe cast error. Aborting... \n";                       //DEBUG
        return;
    }

    transferPlot->rescaleAxes();
    transferPlot->replot();

    myPDiag->setModal(false);
    myPDiag->show();

    removePlot();

    return;
}
开发者ID:Yarr,项目名称:Yarr,代码行数:81,代码来源:yarrgui.cpp

示例11: doScan


//.........这里部分代码省略.........

        //clear raw data
        while(fe->clipDataFei4->size() != 0){
            fe->clipDataFei4->popData();
        }

        //clear raw data
        while(fe->clipHisto->size() != 0){
            fe->clipHisto->popData();
        }

        while(fe->clipResult->size() != 0){
            HistogramBase * showMe = fe->clipResult->popData();

            //Add tab to plot tab widget
            QCustomPlot * tabScanPlot = new QCustomPlot(ui->scanPlots_tabWidget); // X
            QWidget * addToTabWidget = dynamic_cast<QWidget*>(tabScanPlot);
            QString newTabName = qn + ' ' + ui->feTree->topLevelItem(j)->text(0);
            ui->scanPlots_tabWidget->addTab(addToTabWidget, newTabName);

            //Add plot to scan tree
            QTreeWidgetItem * plotTreeItemP = new QTreeWidgetItem(plotTreeItemDS); // X
            plotTreeItemP->setText(0, "Plot " + QString::number(plotTreeItemDS->childCount())
                                              + " (" + QString::fromStdString(showMe->getName()) + ")");
            plotTreeItemDS->addChild(plotTreeItemP);

            if(dynamic_cast<Histo2d*>(showMe) != nullptr){
                Histo2d * myHist2d = dynamic_cast<Histo2d*>(showMe);
                //Create plot

                QCPColorMap * colorMap = new QCPColorMap(tabScanPlot->xAxis, tabScanPlot->yAxis);
                QCPColorScale * colorScale = new QCPColorScale(tabScanPlot);

                tabScanPlot->addPlottable(colorMap);
                tabScanPlot->plotLayout()->insertRow(0);
                tabScanPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(tabScanPlot, QString::fromStdString(myHist2d->getName())));

                colorMap->setName(QString::fromStdString(myHist2d->getName()));
                colorMap->data()->setSize(80, 336);
                colorMap->data()->setRange(QCPRange(0, 80), QCPRange(0, 336));
                colorMap->keyAxis()->setLabel(QString::fromStdString(myHist2d->getXaxisTitle()));
                colorMap->valueAxis()->setLabel(QString::fromStdString(myHist2d->getYaxisTitle()));
                for(int xCoord = 0; xCoord<80; xCoord++){
                    for(int yCoord = 0; yCoord<336; yCoord++){
                        double colVal = myHist2d->getBin(yCoord + 336*xCoord);              //TODO make better
                        colorMap->data()->setCell(xCoord, yCoord, colVal);
                    }
                }

                tabScanPlot->plotLayout()->addElement(1, 1, colorScale);
                colorScale->setType(QCPAxis::atRight);
                colorMap->setColorScale(colorScale);
                colorScale->axis()->setLabel(QString::fromStdString(myHist2d->getZaxisTitle()));
                colorMap->setGradient(QCPColorGradient::gpPolar);
                colorMap->rescaleDataRange();

            }else if(dynamic_cast<Histo1d*>(showMe) != nullptr){
                Histo1d * myHist1d = dynamic_cast<Histo1d*>(showMe);

                QCPBars * myBars = new QCPBars(tabScanPlot->xAxis, tabScanPlot->yAxis);
                tabScanPlot->addPlottable(myBars);
                myBars->setName(QString::fromStdString(myHist1d->getName()));

                for(unsigned int i = 0; i < myHist1d->size(); i++) {
                    myBars->addData((double)(i+1), myHist1d->getBin(i));
                }
开发者ID:Yarr,项目名称:Yarr,代码行数:67,代码来源:yarrgui.cpp


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