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


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

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


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

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

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


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