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


C++ QCustomPlot类代码示例

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


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

示例1: resetAxes

void TCPStreamDialog::resetAxes()
{
    QCustomPlot *sp = ui->streamPlot;

    y_axis_xfrm_.reset();
    double pixel_pad = 10.0; // per side

    sp->rescaleAxes(true);
    tput_graph_->rescaleValueAxis(false, true);
//    base_graph_->rescaleAxes(false, true);
//    for (int i = 0; i < sp->graphCount(); i++) {
//        sp->graph(i)->rescaleValueAxis(false, true);
//    }

    double axis_pixels = sp->xAxis->axisRect()->width();
    sp->xAxis->scaleRange((axis_pixels + (pixel_pad * 2)) / axis_pixels, sp->xAxis->range().center());

    if (sp->yAxis2->visible()) {
        double ratio = sp->yAxis2->range().size() / sp->yAxis->range().size();
        y_axis_xfrm_.translate(0.0, sp->yAxis2->range().lower - (sp->yAxis->range().lower * ratio));
        y_axis_xfrm_.scale(1.0, ratio);
    }

    axis_pixels = sp->yAxis->axisRect()->height();
    sp->yAxis->scaleRange((axis_pixels + (pixel_pad * 2)) / axis_pixels, sp->yAxis->range().center());

    sp->replot();
}
开发者ID:crondaemon,项目名称:wireshark,代码行数:28,代码来源:tcp_stream_dialog.cpp

示例2: sequence_analysis_list_free

void SequenceDialog::fillDiagram()
{
    if (!sainfo_ || file_closed_) return;

    QCustomPlot *sp = ui->sequencePlot;

    if (sainfo_->type == SEQ_ANALYSIS_VOIP) {
        seq_diagram_->setData(sainfo_);
    } else {
        seq_diagram_->clearData();
        sequence_analysis_list_free(sainfo_);
        sequence_analysis_list_get(cap_file_.capFile(), sainfo_);
        num_items_ = sequence_analysis_get_nodes(sainfo_);
        seq_diagram_->setData(sainfo_);
    }

    QFontMetrics vfm = QFontMetrics(sp->xAxis2->labelFont());
    char* addr_str;
    node_label_w_ = 0;
    for (guint i = 0; i < sainfo_->num_nodes; i++) {
        addr_str = (char*)address_to_display(NULL, &(sainfo_->nodes[i]));
        int label_w = vfm.width(addr_str);
        if (node_label_w_ < label_w) {
            node_label_w_ = label_w;
        }
        wmem_free(NULL, addr_str);
    }
    node_label_w_ = (node_label_w_ * 3 / 4) + one_em_;

    mouseMoved(NULL);
    resetAxes();

    // XXX QCustomPlot doesn't seem to draw any sort of focus indicator.
    sp->setFocus();
}
开发者ID:JunichiWatanuki,项目名称:wireshark,代码行数:35,代码来源:sequence_dialog.cpp

示例3: panAxes

void SequenceDialog::panAxes(int x_pixels, int y_pixels)
{
    // We could simplify this quite a bit if we set the scroll bar values instead.
    if (!info_->sainfo()) return;

    QCustomPlot *sp = ui->sequencePlot;
    double h_pan = 0.0;
    double v_pan = 0.0;

    h_pan = sp->xAxis2->range().size() * x_pixels / sp->xAxis2->axisRect()->width();
    if (h_pan < 0) {
        h_pan = qMax(h_pan, min_left_ - sp->xAxis2->range().lower);
    } else {
        h_pan = qMin(h_pan, info_->sainfo()->num_nodes - sp->xAxis2->range().upper);
    }

    v_pan = sp->yAxis->range().size() * y_pixels / sp->yAxis->axisRect()->height();
    if (v_pan < 0) {
        v_pan = qMax(v_pan, min_top_ - sp->yAxis->range().lower);
    } else {
        v_pan = qMin(v_pan, num_items_ - sp->yAxis->range().upper);
    }

    if (h_pan && !(sp->xAxis2->range().contains(min_left_) && sp->xAxis2->range().contains(info_->sainfo()->num_nodes))) {
        sp->xAxis2->moveRange(h_pan);
        sp->replot();
    }
    if (v_pan && !(sp->yAxis->range().contains(min_top_) && sp->yAxis->range().contains(num_items_))) {
        sp->yAxis->moveRange(v_pan);
        sp->replot();
    }
}
开发者ID:kynesim,项目名称:wireshark,代码行数:32,代码来源:sequence_dialog.cpp

示例4: resetAxes

void LBMUIMFlowDialog::resetAxes(bool keep_lower)
{
    QCustomPlot * sp = m_ui->sequencePlot;
    // Allow space for labels on the top and port numbers on the left.
    double top_pos = -1.0, left_pos = -0.5;
    if (keep_lower)
    {
        top_pos = sp->yAxis->range().lower;
        left_pos = sp->xAxis2->range().lower;
    }

    double range_ratio = sp->xAxis2->axisRect()->width() / m_node_label_width;
    sp->xAxis2->setRange(left_pos, range_ratio + left_pos);

    range_ratio = sp->yAxis->axisRect()->height() / (m_one_em * 1.5);
    sp->yAxis->setRange(top_pos, range_ratio + top_pos);

    double rmin = sp->xAxis2->range().size() / 2;
    m_ui->horizontalScrollBar->setRange((rmin - 0.5) * 100, (m_sequence_analysis.num_nodes - 0.5 - rmin) * 100);
    xAxisChanged(sp->xAxis2->range());

    rmin = (sp->yAxis->range().size() / 2);
    m_ui->verticalScrollBar->setRange((rmin - 1.0) * 100, (m_num_items - 0.5 - rmin) * 100);
    yAxisChanged(sp->yAxis->range());

    sp->replot();
}
开发者ID:appneta,项目名称:wireshark,代码行数:27,代码来源:lbm_uimflow_dialog.cpp

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

示例6: removeAllGraphs

void viewGVpropertieslayout::removeAllGraphs()
{
    // first get a pointer to the current plot!
    QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget();
    currPlot->clearGraphs();
    currPlot->replot();
}
开发者ID:ajc158,项目名称:spinecreator,代码行数:7,代码来源:viewGVpropertieslayout.cpp

示例7: pow

void LteRlcGraphDialog::zoomYAxis(bool in)
{
    QCustomPlot *rp = ui->rlcPlot;
    double v_factor = rp->axisRect()->rangeZoomFactor(Qt::Vertical);

    if (in) {
        // Don't want to zoom in *too* far on y axis.
        if (rp->yAxis->range().size() < 10) {
            return;
        }
    }
    else {
        // Don't want to zoom out *too* far on y axis.
        if (rp->yAxis->range().size() > (65536+10)) {
            return;
        }
    }

    if (!in) {
        v_factor = pow(v_factor, -1);
    }

    rp->yAxis->scaleRange(v_factor, rp->yAxis->range().center());
    rp->replot(QCustomPlot::rpQueued);
}
开发者ID:kimkucheol,项目名称:wireshark,代码行数:25,代码来源:lte_rlc_graph_dialog.cpp

示例8: panAxes

void LteRlcGraphDialog::panAxes(int x_pixels, int y_pixels)
{
    QCustomPlot *rp = ui->rlcPlot;
    double h_pan = 0.0;
    double v_pan = 0.0;

    // Don't scroll up beyond max range, or below 0
    if (((y_pixels > 0) && (rp->yAxis->range().upper > 65536)) ||
        ((y_pixels < 0) && (rp->yAxis->range().lower < 0))) {
        return;
    }
    // Don't scroll left beyond 0.  Arguably should be time of first segment.
    if ((x_pixels < 0) && (rp->xAxis->range().lower < 0)) {
        return;
    }

    h_pan = rp->xAxis->range().size() * x_pixels / rp->xAxis->axisRect()->width();
    v_pan = rp->yAxis->range().size() * y_pixels / rp->yAxis->axisRect()->height();

    // The GTK+ version won't pan unless we're zoomed. Should we do the same here?
    if (h_pan) {
        rp->xAxis->moveRange(h_pan);
        rp->replot(QCustomPlot::rpQueued);
    }
    if (v_pan) {
        rp->yAxis->moveRange(v_pan);
        rp->replot(QCustomPlot::rpQueued);
    }
}
开发者ID:kimkucheol,项目名称:wireshark,代码行数:29,代码来源:lte_rlc_graph_dialog.cpp

示例9: mouseMoved

void SequenceDialog::mouseMoved(QMouseEvent *event)
{
    QCustomPlot *sp = ui->sequencePlot;
    Qt::CursorShape shape = Qt::ArrowCursor;
    if (event) {
        if (event->buttons().testFlag(Qt::LeftButton)) {
            shape = Qt::ClosedHandCursor;
        } else {
            if (sp->axisRect()->rect().contains(event->pos())) {
                shape = Qt::OpenHandCursor;
            }
        }
    }
    sp->setCursor(QCursor(shape));

    packet_num_ = 0;
    QString hint;
    if (event) {
        seq_analysis_item_t *sai = seq_diagram_->itemForPosY(event->pos().y());
        if (sai) {
            packet_num_ = sai->fd->num;
            hint = QString("Packet %1: %2").arg(packet_num_).arg(sai->comment);
        }
    }

    if (hint.isEmpty()) {
        hint += tr("%Ln node(s)", "", seq_analysis_.num_nodes) + QString(", ")
                + tr("%Ln item(s)", "", num_items_);
    }

    hint.prepend("<small><i>");
    hint.append("</i></small>");
    ui->hintLabel->setText(hint);
}
开发者ID:dot-Sean,项目名称:wireshark-http2,代码行数:34,代码来源:sequence_dialog.cpp

示例10: sequence_analysis_list_get

void SequenceDialog::fillDiagram()
{
    QCustomPlot *sp = ui->sequencePlot;
    seq_analysis_info_t new_sa;

    new_sa = seq_analysis_;
    new_sa.list = NULL;
    new_sa.ht = NULL;
    new_sa.num_nodes = 0;
    sequence_analysis_list_get(cap_file_, &new_sa);
    num_items_ = sequence_analysis_get_nodes(&new_sa);
    seq_diagram_->setData(&new_sa);
    sequence_analysis_list_free(&seq_analysis_);
    seq_analysis_ = new_sa;

    QFontMetrics vfm = QFontMetrics(sp->xAxis2->labelFont());
    node_label_w_ = 0;
    for (guint i = 0; i < seq_analysis_.num_nodes; i++) {
        int label_w = vfm.width(ep_address_to_display(&(seq_analysis_.nodes[i])));
        if (node_label_w_ < label_w) {
            node_label_w_ = label_w;
        }
    }
    node_label_w_ = (node_label_w_ * 3 / 4) + one_em_;

    mouseMoved(NULL);
    resetAxes();

    // XXX QCustomPlot doesn't seem to draw any sort of focus indicator.
    sp->setFocus();
}
开发者ID:dot-Sean,项目名称:wireshark-http2,代码行数:31,代码来源:sequence_dialog.cpp

示例11: resetAxes

void SequenceDialog::resetAxes(bool keep_lower)
{
    if (!sainfo_) return;

    QCustomPlot *sp = ui->sequencePlot;
    // Allow space for labels on the top and port numbers on the left.
    double top_pos = -1.0, left_pos = -0.5;
    if (keep_lower) {
        top_pos = sp->yAxis->range().lower;
        left_pos = sp->xAxis2->range().lower;
    }

    double range_ratio = sp->xAxis2->axisRect()->width() / node_label_w_;
    sp->xAxis2->setRange(left_pos, range_ratio + left_pos);

    range_ratio = sp->yAxis->axisRect()->height() / (one_em_ * 1.5);
    sp->yAxis->setRange(top_pos, range_ratio + top_pos);

    double rmin = sp->xAxis2->range().size() / 2;
    ui->horizontalScrollBar->setRange((rmin - 0.5) * 100, (sainfo_->num_nodes - 0.5 - rmin) * 100);
    xAxisChanged(sp->xAxis2->range());

    rmin = (sp->yAxis->range().size() / 2);
    ui->verticalScrollBar->setRange((rmin - 1.0) * 100, (num_items_ - 0.5 - rmin) * 100);
    yAxisChanged(sp->yAxis->range());

    sp->replot();
}
开发者ID:JunichiWatanuki,项目名称:wireshark,代码行数:28,代码来源:sequence_dialog.cpp

示例12: g_queue_new

void LBMUIMFlowDialog::fillDiagram(void)
{
    QCustomPlot * sp = m_ui->sequencePlot;
    seq_analysis_info_t new_sa;

    new_sa = m_sequence_analysis;
    new_sa.items = g_queue_new();
    new_sa.ht = NULL;
    new_sa.num_nodes = 0;
    lbm_uimflow_get_analysis(m_capture_file, &new_sa);
    m_num_items = sequence_analysis_get_nodes(&new_sa);
    m_sequence_diagram->setData(&new_sa);
    sequence_analysis_list_free(&m_sequence_analysis);
    m_sequence_analysis = new_sa;

    QFontMetrics vfm = QFontMetrics(sp->xAxis2->labelFont());
    m_node_label_width = 0;
    for (guint i = 0; i < m_sequence_analysis.num_nodes; i++)
    {
        QString addr_str = address_to_display_qstring(&(m_sequence_analysis.nodes[i]));
        int label_w = vfm.width(addr_str);
        if (m_node_label_width < label_w)
        {
            m_node_label_width = label_w;
        }
    }
    m_node_label_width = (m_node_label_width * 3 / 4) + m_one_em;

    mouseMoved(NULL);
    resetAxes();

    // XXX QCustomPlot doesn't seem to draw any sort of focus indicator.
    sp->setFocus();
}
开发者ID:appneta,项目名称:wireshark,代码行数:34,代码来源:lbm_uimflow_dialog.cpp

示例13: main

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  QMainWindow window;
  
  // setup customPlot as central widget of window:
  QCustomPlot customPlot;
  window.setCentralWidget(&customPlot);
  
  // create plot (from quadratic plot example):
  QVector<double> x(101), y(101);
  for (int i=0; i<101; ++i)
  {
    x[i] = i/50.0 - 1;
    y[i] = x[i]*x[i];
  }
  customPlot.addGraph();
  customPlot.graph(0)->setData(x, y);
  customPlot.xAxis->setLabel(QLatin1String("x"));
  customPlot.yAxis->setLabel(QLatin1String("y"));
  customPlot.rescaleAxes();
  
  window.setGeometry(100, 100, 500, 400);
  window.show();
  return a.exec();
}
开发者ID:alagoutte,项目名称:QCustomPlot,代码行数:26,代码来源:main.cpp

示例14: on_exportPlotCSVButton_clicked

void YarrGui::on_exportPlotCSVButton_clicked(){
    if(ui->scanPlots_tabWidget->count() == 0){return;}
    if(ui->plotTree->currentItem() == nullptr) {
        std::cerr << "Please select plot. Returning... " << std::endl;
        return;
    }
    if(ui->plotTree->currentItem()->childCount() > 0){
        std::cerr << "Please select plot. Returning... " << std::endl;
        return;
    }

    QWidget * toCast = ui->scanPlots_tabWidget->currentWidget();
    QCustomPlot * myPlot = dynamic_cast<QCustomPlot*>(toCast);
    if(myPlot == nullptr){
        std::cerr << "Severe cast error. Returning... " << std::endl;
        return;
    }

    QCPColorMap * myColorMap = dynamic_cast<QCPColorMap*>(myPlot->plottable());
    if(myColorMap == nullptr){
        std::cout << "Severe cast error. Aborting... " << std::endl;
        return;
    }

/*    QString myFileName = ui->plotTree->currentItem()->text(0);

    struct tm * timeinfo;
    time_t rawtime;
    time(&rawtime);
    timeinfo = localtime(&rawtime);

    myFileName = myFileName
               + QString::number(1900+(timeinfo->tm_year)) + '_'
               + (timeinfo->tm_mon > 8 ? QString::number(1+(timeinfo->tm_mon)) : ('0' + QString::number(1+(timeinfo->tm_mon)))) + '_'
               + QString::number((timeinfo->tm_mday)) + '_'
               + QString::number((timeinfo->tm_hour)) + '_'
               + QString::number((timeinfo->tm_min)) + '_'
               + QString::number((timeinfo->tm_sec)) + ".csv";
*/

    QString myFileName = QFileDialog::getSaveFileName(this,
                                                      "Save plot as CSV",
                                                      "./",
                                                      "Comma-Separated Values(*.csv)");
    if(myFileName==""){return;}

    std::ofstream myCSVOutput(myFileName.toStdString());

    for(int xCoord = 0; xCoord<80; xCoord++){
        for(int yCoord = 0; yCoord<336; yCoord++) {
            myCSVOutput << xCoord << ",\t" << yCoord << ",\t" << myColorMap->data()->cell(xCoord, yCoord) << std::endl;
        }
    }

    myCSVOutput.close();
    std::cout << "Saved current plot to \"" << myFileName.toStdString() << '"' << std::endl;

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

示例15: PlotContextMenuRequest

void MainWindow::PlotContextMenuRequest(QPoint)
{
    QCustomPlot * plot = qobject_cast<QCustomPlot *>(sender());
    ui->actionEdit_plot->setText(QString("Edit \"%1\"").arg(plot->title()));
    ui->actionRemove_plot->setText(QString("Remove \"%1\"").arg(plot->title()));
    ui->actionEdit_plot->setProperty("Plot",QVariant::fromValue((QWidget *)plot));
    ui->actionRemove_plot->setProperty("Plot",QVariant::fromValue((QWidget *)plot));
    plotMenu->popup(QCursor::pos());
}
开发者ID:kubanecxxx,项目名称:StMaster,代码行数:9,代码来源:mainwindow.cpp


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