Skip to content

Commit

Permalink
Merge pull request #3274 from enetz/feature/colored_peaks
Browse files Browse the repository at this point in the history
[FEATURE] TOPPView: peaks colored by label content
  • Loading branch information
timosachsenberg committed Mar 1, 2018
2 parents b78f984 + 47feb7e commit f8f7544
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/openms_gui/include/OpenMS/VISUAL/LayerData.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ namespace OpenMS
gradient(),
filters(),
annotations_1d(),
peak_colors_1d(),
modifiable(false),
modified(false),
label(L_NONE),
Expand Down Expand Up @@ -308,6 +309,9 @@ namespace OpenMS
/// Annotations of all spectra of the experiment (1D view)
std::vector<Annotations1DContainer> annotations_1d;

/// Peak colors of the currently shown spectrum
std::vector<QColor> peak_colors_1d;

/// Flag that indicates if the layer data can be modified (so far used for features only)
bool modifiable;

Expand Down
10 changes: 10 additions & 0 deletions src/openms_gui/source/VISUAL/Spectrum1DCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,16 @@ namespace OpenMS
{
if (layer.filters.passes(spectrum, it - spectrum.begin()))
{

// use peak colors stored in the layer, if available
if (layer.peak_colors_1d.size() == spectrum.size())
{
// find correct peak index
Size peak_index = std::distance(spectrum.begin(), it);
pen.setColor(layer.peak_colors_1d[peak_index]);
painter->setPen(pen);
}

dataToWidget(*it, end, layer.flipped);
dataToWidget(it->getMZ(), 0.0f, begin, layer.flipped);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,24 +935,30 @@ namespace OpenMS
ann_spectrum[i].getIntensity());
const String& label = labels[i];
QColor color;
QColor peak_color;
LayerData& annotated_layer = current_canvas->getCurrentLayer();
// XL-MS specific coloring of the labels, green for linear fragments and red for cross-linked fragments
if (label.hasSubstring("[alpha|") || label.hasSubstring("[beta|"))
{
if (label.hasSubstring("|ci$"))
{
color = Qt::darkGreen;
peak_color = Qt::green;
}
else if (label.hasSubstring("|xi$"))
{
color = Qt::darkRed;
peak_color = Qt::red;
}
}
else // different colors for left/right fragments (e.g. b/y ions)
{
color = (label.at(0) < 'n') ? Qt::darkRed : Qt::darkGreen;
peak_color = (label.at(0) < 'n') ? Qt::red : Qt::green;
}

Annotation1DItem* item = new Annotation1DPeakItem(position, label.toQString(), color);
annotated_layer.peak_colors_1d.push_back(peak_color);
item->setSelected(false);
tv_->getActive1DWidget()->canvas()->getCurrentLayer().getCurrentAnnotations().push_front(item);
}
Expand Down

0 comments on commit f8f7544

Please sign in to comment.