| 387 | } |
| 388 | |
| 389 | void SpectraIDViewTab::currentCellChanged_(int row, int column, int /*old_row*/, int /*old_column*/) |
| 390 | { |
| 391 | // TODO you actually only have to do repainting if the row changes.. |
| 392 | // sometimes Qt calls this function when table empty during refreshing |
| 393 | if (row < 0 || column < 0) |
| 394 | { |
| 395 | return; |
| 396 | } |
| 397 | |
| 398 | if (row >= table_widget_->rowCount() |
| 399 | || column >= table_widget_->columnCount()) |
| 400 | { |
| 401 | throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, "invalid cell clicked.", String(row) + " " + column); |
| 402 | } |
| 403 | |
| 404 | // deselect whatever is currently shown (if we are in 1D view) |
| 405 | auto* layer_1d = dynamic_cast<LayerData1DPeak*>(layer_); |
| 406 | if (layer_1d) |
| 407 | { |
| 408 | emit spectrumDeselected(int(layer_1d->getCurrentIndex())); |
| 409 | } |
| 410 | |
| 411 | int current_spectrum_index = table_widget_->item(row, Clmn::SPEC_INDEX)->data(Qt::DisplayRole).toInt(); |
| 412 | const auto& exp = *layer_->getPeakData(); |
| 413 | const auto& spec2 = exp[current_spectrum_index]; |
| 414 | |
| 415 | // |
| 416 | // Signal for a new spectrum to be shown |
| 417 | // |
| 418 | // show precursor spectrum (usually MS1) |
| 419 | if (column == Clmn::PRECURSOR_MZ) |
| 420 | { |
| 421 | const auto prec_it = exp.getPrecursorSpectrum(exp.begin() + current_spectrum_index); |
| 422 | |
| 423 | if (prec_it != exp.end() && !spec2.getPrecursors().empty()) |
| 424 | { |
| 425 | double precursor_mz = spec2.getPrecursors()[0].getMZ(); |
| 426 | // determine start and stop of isolation window |
| 427 | double isolation_window_lower_mz = precursor_mz - spec2.getPrecursors()[0].getIsolationWindowLowerOffset(); |
| 428 | double isolation_window_upper_mz = precursor_mz + spec2.getPrecursors()[0].getIsolationWindowUpperOffset(); |
| 429 | |
| 430 | emit spectrumSelected(std::distance(exp.begin(), prec_it), -1, -1);// no identification or hit selected (-1) |
| 431 | // zoom into precursor area |
| 432 | emit requestVisibleArea1D(isolation_window_lower_mz - 50.0, isolation_window_upper_mz + 50.0); |
| 433 | } |
| 434 | } |
| 435 | else |
| 436 | {// if spectrum with no PepIDs is selected, there is nothing to show... |
| 437 | auto item_pepid = table_widget_->item(row, Clmn::ID_NR); |
| 438 | if (item_pepid == nullptr// null for MS1 spectra |
| 439 | || (!(item_pepid->data(Qt::DisplayRole).isValid()))) |
| 440 | { |
| 441 | return; |
| 442 | } |
| 443 | int current_identification_index = item_pepid->data(Qt::DisplayRole).toInt(); |
| 444 | int current_peptide_hit_index = table_widget_->item(row, Clmn::PEPHIT_NR)->data(Qt::DisplayRole).toInt(); |
| 445 | emit spectrumSelected(current_spectrum_index, current_identification_index, current_peptide_hit_index); |
| 446 | } |
nothing calls this directly
no test coverage detected