| 388 | } |
| 389 | |
| 390 | void PlotDataDialog::plot() { |
| 391 | WAIT_CURSOR; |
| 392 | m_parentAspect->project()->setSuppressAspectAddedSignal(true); |
| 393 | m_lastAddedCurve = nullptr; |
| 394 | |
| 395 | if (ui->rbPlotPlacementExistingPlotArea->isChecked()) { |
| 396 | // add curves to an existing plot |
| 397 | auto* aspect = static_cast<AbstractAspect*>(cbExistingPlots->currentModelIndex().internalPointer()); |
| 398 | auto* plot = static_cast<CartesianPlot*>(aspect); |
| 399 | plot->beginMacro(i18n("Plot Area - %1", m_parentAspect->name())); |
| 400 | addCurvesToPlot(plot); |
| 401 | plot->endMacro(); |
| 402 | } else if (ui->rbPlotPlacementExistingWorksheet->isChecked()) { |
| 403 | // add curves to a new plot in an existing worksheet |
| 404 | auto* aspect = static_cast<AbstractAspect*>(cbExistingWorksheets->currentModelIndex().internalPointer()); |
| 405 | auto* worksheet = static_cast<Worksheet*>(aspect); |
| 406 | worksheet->beginMacro(i18n("Worksheet - %1", m_parentAspect->name())); |
| 407 | |
| 408 | if (ui->rbCurvePlacementAllInOnePlotArea->isChecked()) { |
| 409 | // all curves in one plot |
| 410 | auto* plot = new CartesianPlot(i18n("Plot Area - %1", m_parentAspect->name())); |
| 411 | plot->setType(CartesianPlot::Type::FourAxes); |
| 412 | worksheet->addChild(plot); |
| 413 | if (m_columnComboBoxes.count() == 2) |
| 414 | setAxesColumnLabels(plot, m_columnComboBoxes.at(1)->currentText()); |
| 415 | |
| 416 | addCurvesToPlot(plot); |
| 417 | setAxesTitles(plot); |
| 418 | } else { |
| 419 | // one plot per curve |
| 420 | addCurvesToPlots(worksheet); |
| 421 | } |
| 422 | worksheet->endMacro(); |
| 423 | } else { |
| 424 | // add curves to a new plot(s) in a new worksheet |
| 425 | auto* parent = m_parentAspect->parentAspect(); |
| 426 | if (parent->type() == AspectType::DatapickerCurve) |
| 427 | parent = parent->parentAspect()->parentAspect(); |
| 428 | else if (parent->type() == AspectType::Workbook) |
| 429 | parent = parent->parentAspect(); |
| 430 | #ifdef HAVE_MQTT |
| 431 | else if (dynamic_cast<MQTTTopic*>(m_parentAspect)) |
| 432 | parent = m_parentAspect->project(); |
| 433 | #endif |
| 434 | parent->beginMacro(i18n("Plot data from %1", m_parentAspect->name())); |
| 435 | auto* worksheet = new Worksheet(i18n("Worksheet - %1", m_parentAspect->name())); |
| 436 | parent->addChild(worksheet); |
| 437 | |
| 438 | if (ui->rbCurvePlacementAllInOnePlotArea->isChecked()) { |
| 439 | // all curves in one plot |
| 440 | auto* plot = new CartesianPlot(i18n("Plot Area - %1", m_parentAspect->name())); |
| 441 | plot->setType(CartesianPlot::Type::FourAxes); |
| 442 | worksheet->addChild(plot); |
| 443 | if (m_columnComboBoxes.count() == 2) |
| 444 | setAxesColumnLabels(plot, m_columnComboBoxes.at(1)->currentText()); |
| 445 | addCurvesToPlot(plot); |
| 446 | setAxesTitles(plot); |
| 447 | } else { |
no test coverage detected