void YarrGui::detachPlot(){ if(ui->plotTree->currentItem() == nullptr){ std::cerr << "Please select plot to detach...\n"; return; } if(ui->plotTree->currentItem()->childCount() > 0){ std::cerr << "Please select plot to detach...\n"; return; } PlotDialog * myPDiag = new PlotDialog(); QCustomPlot * plotWidget = dynamic_cast<QCustomPlot*>(ui->scanPlots_tabWidget->currentWidget()); if(plotWidget == nullptr){ std::cerr << "Severe cast error. Aborting...\n"; return; } QCustomPlot * transferPlot = dynamic_cast<QCustomPlot*>(myPDiag->childAt(10, 10)); if(transferPlot == nullptr){ std::cerr << "Severe cast error. Aborting...\n"; return; } QCPPlotTitle * widgetPT = dynamic_cast<QCPPlotTitle*>(plotWidget->plotLayout()->element(0, 0)); if(widgetPT == nullptr){ std::cerr << "Severe cast error. Aborting... \n"; return; } if(dynamic_cast<QCPColorMap*>(plotWidget->plottable(0)) != nullptr){ QCPColorMap * widgetCMap = dynamic_cast<QCPColorMap*>(plotWidget->plottable(0)); QCPColorScale * widgetCScale = dynamic_cast<QCPColorScale*>(plotWidget->plotLayout()->element(1, 1)); if(widgetCScale == nullptr) { std::cerr << "Severe cast error. Aborting... \n"; return; } transferPlot->plotLayout()->insertRow(0); transferPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(transferPlot, widgetPT->text())); QCPColorMap * transferCMap = new QCPColorMap(transferPlot->xAxis, transferPlot->yAxis); transferPlot->addPlottable(transferCMap); transferCMap->data()->setSize(80, 336); transferCMap->setData(widgetCMap->data(), true); QCPColorScale * transferCScale = new QCPColorScale(transferPlot); transferPlot->plotLayout()->addElement(1, 1, transferCScale); transferCScale->setType(QCPAxis::atRight); transferCMap->setColorScale(transferCScale); transferCMap->keyAxis()->setLabel(widgetCMap->keyAxis()->label()); transferCMap->valueAxis()->setLabel(widgetCMap->valueAxis()->label()); transferCScale->axis()->setLabel(widgetCScale->axis()->label()); transferCMap->setGradient(QCPColorGradient::gpPolar); transferCMap->rescaleDataRange(); }else if(dynamic_cast<QCPBars*>(plotWidget->plottable(0)) != nullptr){ QCPBars * widgetBars = dynamic_cast<QCPBars*>(plotWidget->plottable(0)); QCPBars * transferBars = new QCPBars(transferPlot->xAxis, transferPlot->yAxis); transferBars->setData(widgetBars->data(), true); transferBars->rescaleAxes(); transferPlot->plotLayout()->insertRow(0); transferPlot->plotLayout()->addElement(0, 0, new QCPPlotTitle(transferPlot, widgetPT->text())); transferBars->keyAxis()->setLabel(widgetBars->keyAxis()->label()); transferBars->valueAxis()->setLabel(widgetBars->valueAxis()->label()); }else{ std::cerr << "Severe cast error. Aborting... \n"; //DEBUG return; } transferPlot->rescaleAxes(); transferPlot->replot(); myPDiag->setModal(false); myPDiag->show(); removePlot(); return; }