MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / copyLayer

Method copyLayer

src/openms_gui/source/VISUAL/APPLICATIONS/TOPPViewBase.cpp:2351–2438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2349 }
2350
2351 void TOPPViewBase::copyLayer(const QMimeData* data, QWidget* source, int id)
2352 {
2353 SpectraTreeTab* spec_view = (source ? qobject_cast<SpectraTreeTab*>(source->parentWidget()) : nullptr);
2354 try
2355 {
2356 // NOT USED RIGHT NOW, BUT KEEP THIS CODE (it was hard to find out how this is done)
2357 // decode data to get the row
2358 // QByteArray encoded_data = data->data(data->formats()[0]);
2359 // QDataStream stream(&encoded_data, QIODevice::ReadOnly);
2360 // int row, col;
2361 // stream >> row >> col;
2362
2363 // set wait cursor
2364 setCursor(Qt::WaitCursor);
2365 RAIICleanup cl([&]() { setCursor(Qt::ArrowCursor); });
2366
2367 // determine where to copy the data
2368 UInt new_id = (id == -1) ? 0 : id;
2369
2370 if (source == layers_view_)
2371 {
2372 // only the selected row can be dragged => the source layer is the selected layer
2373 LayerDataBase& layer = getActiveCanvas()->getCurrentLayer();
2374
2375 // attach feature, consensus and peak data (new OnDiscMSExperiment());
2376 FeatureMapSharedPtrType features(new FeatureMapType());
2377 if (auto* lp = dynamic_cast<LayerDataFeature*>(&layer)) features = lp->getFeatureMap();
2378
2379 ConsensusMapSharedPtrType consensus(new ConsensusMapType());
2380 if (auto* lp = dynamic_cast<LayerDataConsensus*>(&layer)) consensus = lp->getConsensusMap();
2381
2382 ExperimentSharedPtrType peaks(new ExperimentType());
2383 ODExperimentSharedPtrType on_disc_peaks(new OnDiscMSExperiment());
2384 if (auto* lp = dynamic_cast<LayerDataPeak*>(&layer))
2385 {
2386 peaks = lp->getPeakDataMuteable();
2387 on_disc_peaks = lp->getOnDiscPeakData();
2388 }
2389 if (auto* lp = dynamic_cast<LayerDataChrom*>(&layer))
2390 {
2391 peaks = lp->getChromatogramData();
2392 on_disc_peaks = lp->getOnDiscPeakData();
2393 }
2394 // if the layer provides identification data -> retrieve it
2395 vector<PeptideIdentification> peptides;
2396 if (auto p = dynamic_cast<IPeptideIds*>(&layer); p != nullptr)
2397 {
2398 peptides = p->getPeptideIds();
2399 }
2400
2401 // add the data
2402 addData(features, consensus, peptides, peaks, on_disc_peaks, layer.type, false, false, true, layer.filename, layer.getName(), new_id);
2403 }
2404 else if (spec_view != nullptr)
2405 {
2406 ExperimentSharedPtrType new_exp_sptr(new ExperimentType());
2407 if (LayerDataBase::DataType current_type; spec_view->getSelectedScan(*new_exp_sptr, current_type))
2408 {

Callers

nothing calls this directly

Calls 4

getCurrentLayerMethod · 0.80
getSelectedScanMethod · 0.80
appendNewHeaderMethod · 0.80
getNameMethod · 0.45

Tested by

no test coverage detected