void SequenceDialog::diagramClicked(QMouseEvent *event) { QCustomPlot *sp = ui->sequencePlot; if (event->button() == Qt::RightButton) { // XXX We should find some way to get sequenceDiagram to handle a // contextMenuEvent instead. ctx_menu_.exec(event->globalPos()); } else if (sp->axisRect()->rect().contains(event->pos())) { sp->setCursor(QCursor(Qt::ClosedHandCursor)); } on_actionGoToPacket_triggered(); }
void SetRange(QCustomPlot& plot, int index, QVariantMap range, QCPAxis::AxisType type) { auto g = plot.graph(index); auto it = range.find("lo"); if (it != range.end()) { switch (type) { case QCPAxis::atLeft: g->valueAxis()->setRangeLower(it->toReal()); break; case QCPAxis::atBottom: g->keyAxis()->setRangeLower(it->toReal()); break; } } it = range.find("up"); if (it != range.end()) { switch (type) { case QCPAxis::atLeft: g->valueAxis()->setRangeUpper(it->toReal()); break; case QCPAxis::atBottom: g->keyAxis()->setRangeUpper(it->toReal()); break; } } }
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(); }
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(); }
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(); }
void viewGVpropertieslayout::removeAllGraphs() { // first get a pointer to the current plot! QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget(); currPlot->clearGraphs(); currPlot->replot(); }
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(); }
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(); } }
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); }
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); }
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); } }
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(); }
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(); }
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(); }
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(); }
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; }
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()); }
void viewGVpropertieslayout::removeSelectedGraph() { // first get a pointer to the current plot! QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget(); if (currPlot->selectedGraphs().size() > 0) { currPlot->removeGraph(currPlot->selectedGraphs().first()); currPlot->replot(); } }
void viewGVpropertieslayout::actionSavePng_triggered() { // first get a pointer to the current plot! QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget(); QString fileName = QFileDialog::getSaveFileName(this, tr("Save graph as png"), "", tr("Png (*.png)")); if (!fileName.isEmpty()) currPlot->savePng(fileName); }
void MainWindow::on_actionAdd_Plot_triggered() { QWidget *widget = new QWidget(); QCustomPlot *customPlot = new QCustomPlot(widget); QString plotName; plotName.setNum(plotList->size()); customPlot->setObjectName(plotName); ui->plotArea->addSubWindow(customPlot); plotList->append(plotName); }
void ChartPage::on_rbDay_clicked() { ui->rbMonth->setChecked(false); ui->rbWeek->setChecked(false); rangeChoice = Day; QCustomPlot *customPlot = ui->chartBlock; double mupper = customPlot->xAxis->range().upper; customPlot->xAxis->setRange(mupper - rangeChoice, mupper); customPlot->replot(); }
void LteRlcGraphDialog::zoomXAxis(bool in) { QCustomPlot *rp = ui->rlcPlot; double h_factor = rp->axisRect()->rangeZoomFactor(Qt::Horizontal); if (!in) { h_factor = pow(h_factor, -1); } rp->xAxis->scaleRange(h_factor, rp->xAxis->range().center()); rp->replot(QCustomPlot::rpQueued); }
void TCPStreamDialog::zoomYAxis(bool in) { QCustomPlot *sp = ui->streamPlot; double v_factor = sp->axisRect()->rangeZoomFactor(Qt::Vertical); if (!in) { v_factor = pow(v_factor, -1); } sp->yAxis->scaleRange(v_factor, sp->yAxis->range().center()); sp->replot(); }
void TCPStreamDialog::zoomXAxis(bool in) { QCustomPlot *sp = ui->streamPlot; double h_factor = sp->axisRect()->rangeZoomFactor(Qt::Horizontal); if (!in) { h_factor = pow(h_factor, -1); } sp->xAxis->scaleRange(h_factor, sp->xAxis->range().center()); sp->replot(); }
void viewGVpropertieslayout::contextMenuRequest(QPoint pos) { // first get a pointer to the current plot! QCustomPlot * currPlot = (QCustomPlot *) currentSubWindow->widget(); QMenu *menu = new QMenu(this); menu->setAttribute(Qt::WA_DeleteOnClose); if (currPlot->legend->selectTest(pos, false) >= 0) // context menu on legend requested { /*menu->addAction("Move to top left", this, SLOT(moveLegend()))->setData((int)(Qt::AlignTop|Qt::AlignLeft)); menu->addAction("Move to top center", this, SLOT(moveLegend()))->setData((int)(Qt::AlignTop|Qt::AlignHCenter)); menu->addAction("Move to top right", this, SLOT(moveLegend()))->setData((int)(Qt::AlignTop|Qt::AlignRight)); menu->addAction("Move to bottom right", this, SLOT(moveLegend()))->setData((int)(Qt::AlignBottom|Qt::AlignRight)); menu->addAction("Move to bottom left", this, SLOT(moveLegend()))->setData((int)(Qt::AlignBottom|Qt::AlignLeft));*/ } else if (currPlot->xAxis->selectTest(pos, false) >= 0 || \ currPlot->xAxis2->selectTest(pos, false) >= 0) { // enable / disable zoom if (currPlot->axisRect()->rangeZoom() & Qt::Horizontal) menu->addAction("Disable zoom on axis", this, SLOT(toggleHorizontalZoom())); else menu->addAction("Enable zoom on axis", this, SLOT(toggleHorizontalZoom())); // enable / diable drag if (currPlot->axisRect()->rangeDrag() & Qt::Horizontal) menu->addAction("Disable drag on axis", this, SLOT(toggleHorizontalDrag())); else menu->addAction("Enable drag on axis", this, SLOT(toggleHorizontalDrag())); } else if (currPlot->yAxis->selectTest(pos, false) >= 0 || \ currPlot->yAxis2->selectTest(pos, false) >= 0) { // enable / disable zoom if (currPlot->axisRect()->rangeZoom() & Qt::Vertical) menu->addAction("Disable zoom on axis", this, SLOT(toggleVerticalZoom())); else menu->addAction("Enable zoom on axis", this, SLOT(toggleVerticalZoom())); // enable / diable drag if (currPlot->axisRect()->rangeDrag() & Qt::Vertical) menu->addAction("Disable drag on axis", this, SLOT(toggleVerticalDrag())); else menu->addAction("Enable drag on axis", this, SLOT(toggleVerticalDrag())); } else { if (currPlot->graphCount() > 0) menu->addAction("Scale axes to fit", this, SLOT(rescaleAxes())); if (currPlot->selectedGraphs().size() > 0) menu->addAction("Remove selected graph", this, SLOT(removeSelectedGraph())); if (currPlot->graphCount() > 0) menu->addAction("Remove all graphs", this, SLOT(removeAllGraphs())); } menu->popup(currPlot->mapToGlobal(pos)); }
void MainWindow::updatePlots() { for(int k=0;k<plotList->size();k++) { QCustomPlot *customPlot = ui->plotArea->findChild<QCustomPlot*>(plotList->value(k)); customPlot->addGraph(); // customPlot->graph(0)->addData(i,i*2); customPlot->xAxis->setLabel("x"); customPlot->yAxis->setLabel("y"); // set axes ranges, so we see all data: customPlot->xAxis->setRange(-100, 100); customPlot->yAxis->setRange(-1000, 1000); customPlot->replot(); } }
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; }
void CompassMotorCalibrationDialog::compassMotCalibration(mavlink_compassmot_status_t *compassmot_status) { if (!m_uasInterface) return; // no active UAS. QCustomPlot* customPlot = ui->customPlot; int index = compassmot_status->throttle/10; customPlot->graph(GRAPH_ID_CURRENT)->addData(index, compassmot_status->current); customPlot->graph(GRAPH_ID_INTERFERENCE)->addData(index, compassmot_status->interference); customPlot->replot(); x_scalar = compassmot_status->CompensationX; y_scalar = compassmot_status->CompensationY; z_scalar = compassmot_status->CompensationZ; }
void MainWindow::addToPlot(std::vector<double> *x, std::vector<double> *y, int graphNum, AlgorithmFactory::ALGORITHM alg) { QCustomPlot *cp = this->ui->plotter; QVector<double> __x = QVector<double>::fromStdVector(*x); QVector<double> __y = QVector<double>::fromStdVector(*y); cp->graph(graphNum)->setData(__x, __y); switch (alg) { default: case AlgorithmFactory::SPHERE: cp->graph(graphNum)->setName("Esfera"); break; case AlgorithmFactory::ROTATED_RASTRIGIN: cp->graph(graphNum)->setName("Rot Rastrigin"); break; case AlgorithmFactory::ROSENBROCK: cp->graph(graphNum)->setName("Rosenbrock"); break; } cp->rescaleAxes(true); cp->replot(); }
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; }