| 572 | } |
| 573 | |
| 574 | void MdfDocument::OnPlotChannelData(wxCommandEvent &) { |
| 575 | IDataGroup* dg = nullptr; |
| 576 | IChannelGroup* cg = nullptr; |
| 577 | IChannel* cn = nullptr; |
| 578 | |
| 579 | const auto selected_id = GetSelectedBlockId(); |
| 580 | auto *selected_block = GetBlock(selected_id); |
| 581 | if (selected_block != nullptr && selected_block->BlockType() == "CN") { |
| 582 | cn = dynamic_cast<IChannel*>(selected_block); |
| 583 | } |
| 584 | |
| 585 | const auto parent_id = GetParentBlockId(); |
| 586 | auto *parent_block = GetBlock(parent_id); |
| 587 | if (parent_block != nullptr && parent_block->BlockType() == "CG") { |
| 588 | cg = dynamic_cast<IChannelGroup*>(parent_block); |
| 589 | } |
| 590 | |
| 591 | const auto grand_parent_id = GetGrandParentBlockId(); |
| 592 | auto *grand_parent_block = GetBlock(grand_parent_id); |
| 593 | if (grand_parent_block != nullptr && grand_parent_block->BlockType() == "DG") { |
| 594 | dg = dynamic_cast<IDataGroup*>(grand_parent_block); |
| 595 | } |
| 596 | auto& app = wxGetApp(); |
| 597 | if (dg == nullptr || cg == nullptr || cn == nullptr || app.GnuPlot().empty()) { |
| 598 | return; |
| 599 | } |
| 600 | const auto* x_axis = cg->GetXChannel(*cn); // Need to show the master channel as well as the data channel |
| 601 | |
| 602 | std::ostringstream title; |
| 603 | if (!cn->Name().empty()) { |
| 604 | title << cn->Name(); |
| 605 | } |
| 606 | |
| 607 | if (!cg->Name().empty()) { |
| 608 | if (!title.str().empty()) { |
| 609 | title << "/"; |
| 610 | } |
| 611 | title << cg->Name(); |
| 612 | } |
| 613 | |
| 614 | if (!dg->Description().empty()) { |
| 615 | if (!title.str().empty()) { |
| 616 | title << "/"; |
| 617 | } |
| 618 | title << dg->Description(); |
| 619 | } |
| 620 | |
| 621 | if (!title.str().empty()) { |
| 622 | title << "/"; |
| 623 | } |
| 624 | title << reader_->ShortName(); |
| 625 | |
| 626 | // Create the observer list |
| 627 | auto observer_list = std::make_unique<mdf::ChannelObserverList>(); |
| 628 | if (x_axis != nullptr) { |
| 629 | observer_list->emplace_back(std::move(mdf::CreateChannelObserver(*dg, *cg, *x_axis))); |
| 630 | } |
| 631 | observer_list->emplace_back(std::move(mdf::CreateChannelObserver(*dg, *cg, *cn))); |
nothing calls this directly
no test coverage detected