bool FeaturePlot::ctrlSShortcut(){ if( !initialized ) return false; QCustomPlot *plot = ui->plot; QString filename = QFileDialog::getSaveFileName(); if( filename == "" ){ return false; } if( filename.endsWith(".png") ){ return plot->savePng( filename, plot->width(), plot->height() ); } if( filename.endsWith(".jpg") ){ return plot->saveJpg( filename, plot->width(), plot->height() ); } if( filename.endsWith(".jpeg") ){ return plot->saveJpg( filename, plot->width(), plot->height() ); } if( filename.endsWith(".pdf") ){ return plot->savePdf( filename, plot->width(), plot->height() ); } //If we get this far then save as a png return plot->savePng( filename, plot->width(), plot->height() ); }
void viewGVpropertieslayout::actionSavePdf_triggered() { // first get a pointer to the current plot! QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget(); QString fileName = QFileDialog::getSaveFileName(this, tr("Save graph as pdf"), "", tr("Pdf (*.pdf)")); if (!fileName.isEmpty()) currPlot->savePdf(fileName); }
void YarrGui::on_exportPlotButton_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; } /* 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)) + ".pdf"; */ QString myFileName = QFileDialog::getSaveFileName(this, "Save plot as PDF", "./", "Portable Document Format(*.pdf)"); myPlot->savePdf(myFileName); std::cout << "Saved current plot to \"" << myFileName.toStdString() << '"' << std::endl; return; }