| 271 | } |
| 272 | |
| 273 | PlotWidget::CurveInfo* PlotWidget::createCurveXYInteractive(const QString& x_key, const QString& y_key) { |
| 274 | if (catalog_ == nullptr) { |
| 275 | return nullptr; |
| 276 | } |
| 277 | const auto x_descriptor = catalog_->curveDescriptor(x_key); |
| 278 | const auto y_descriptor = catalog_->curveDescriptor(y_key); |
| 279 | if (!x_descriptor.has_value() || !y_descriptor.has_value()) { |
| 280 | return nullptr; |
| 281 | } |
| 282 | |
| 283 | XYCurveDialog dialog(curveDisplayName(*x_descriptor), curveDisplayName(*y_descriptor), this); |
| 284 | while (dialog.exec() == QDialog::Accepted) { |
| 285 | const QString alias = dialog.alias(); |
| 286 | if (curveFromTitle(alias) != nullptr) { |
| 287 | MessageBox::warning( |
| 288 | this, tr("Duplicate name"), tr("A curve named \"%1\" already exists in this plot.").arg(alias)); |
| 289 | continue; |
| 290 | } |
| 291 | // The dialog reports whether the user swapped X and Y relative to the arguments. |
| 292 | const QString final_x = dialog.swapped() ? y_key : x_key; |
| 293 | const QString final_y = dialog.swapped() ? x_key : y_key; |
| 294 | return addCurveXY(final_x, final_y, alias); |
| 295 | } |
| 296 | return nullptr; // cancelled |
| 297 | } |
| 298 | |
| 299 | void PlotWidget::setZoomRectangle(QRectF rect, bool emit_signal) { |
| 300 | if (isXYPlot() && keepRatioXY()) { |
no test coverage detected