diff --git a/source/VISUAL/Spectrum1DCanvas.C b/source/VISUAL/Spectrum1DCanvas.C index 10c8853e740..b7f7b6742d3 100644 --- a/source/VISUAL/Spectrum1DCanvas.C +++ b/source/VISUAL/Spectrum1DCanvas.C @@ -640,6 +640,9 @@ namespace OpenMS void Spectrum1DCanvas::setDrawMode(DrawModes mode) { + //no layers + if (layers_.size()==0) return; + if (draw_modes_[current_layer_]!=mode) { draw_modes_[current_layer_] = mode; @@ -650,6 +653,9 @@ namespace OpenMS Spectrum1DCanvas::DrawModes Spectrum1DCanvas::getDrawMode() const { + //no layers + if (layers_.size()==0) return DM_PEAKS; + return draw_modes_[current_layer_]; } @@ -1087,11 +1093,12 @@ namespace OpenMS { if (intensity_mode_ == IM_SNAP) { - double local_max = -numeric_limits::max(); + DoubleReal local_max = -numeric_limits::max(); for (Size i=0; igetIntensity() > local_max) + SpectrumType& spectrum = getLayer_(i).getCurrentSpectrum(); + SpectrumIteratorType tmp = max_element(spectrum.MZBegin(visible_area_.minX()), spectrum.MZEnd(visible_area_.maxX()), PeakType::IntensityLess()); + if (tmp != spectrum.end() && tmp->getIntensity() > local_max) { local_max = tmp->getIntensity(); } diff --git a/source/VISUAL/Spectrum2DWidget.C b/source/VISUAL/Spectrum2DWidget.C index c285cb2a5d5..40f10e33a96 100644 --- a/source/VISUAL/Spectrum2DWidget.C +++ b/source/VISUAL/Spectrum2DWidget.C @@ -283,10 +283,21 @@ namespace OpenMS { projection_horz_->showLegend(false); projection_horz_->canvas()->setIntensityMode(SpectrumCanvas::IM_PERCENTAGE); - projection_horz_->canvas()->removeLayer(0); - ExperimentType tmp = exp; - projection_horz_->canvas()->addLayer(tmp); - projection_horz_->canvas()->setDrawMode(mode); + if (!projectionsVisible() || projection_horz_->canvas()->getLayerCount()==0) //set draw mode + { + projection_horz_->canvas()->removeLayer(0); + ExperimentType tmp(exp); //we need a copy to swap the content into the canvas + projection_horz_->canvas()->addLayer(tmp); + projection_horz_->canvas()->setDrawMode(mode); + } + else //keep draw mode + { + Spectrum1DCanvas::DrawModes previous_mode = projection_horz_->canvas()->getDrawMode(); + projection_horz_->canvas()->removeLayer(0); + ExperimentType tmp(exp); //we need a copy to swap the content into the canvas + projection_horz_->canvas()->addLayer(tmp); + projection_horz_->canvas()->setDrawMode(previous_mode); + } grid_->setColumnStretch(3,2); projection_horz_->show(); projection_box_->show(); @@ -297,10 +308,21 @@ namespace OpenMS projection_vert_->canvas()->mzToXAxis(false); projection_vert_->showLegend(false); projection_vert_->canvas()->setIntensityMode(SpectrumCanvas::IM_PERCENTAGE); - projection_vert_->canvas()->removeLayer(0); - ExperimentType tmp = exp; - projection_vert_->canvas()->addLayer(tmp); - projection_vert_->canvas()->setDrawMode(mode); + if (!projectionsVisible() || projection_vert_->canvas()->getLayerCount()==0) //set draw mode + { + projection_vert_->canvas()->removeLayer(0); + ExperimentType tmp(exp); //we need a copy to swap the content into the canvas + projection_vert_->canvas()->addLayer(tmp); + projection_vert_->canvas()->setDrawMode(mode); + } + else //keep draw mode + { + Spectrum1DCanvas::DrawModes previous_mode = projection_vert_->canvas()->getDrawMode(); + projection_vert_->canvas()->removeLayer(0); + ExperimentType tmp(exp); //we need a copy to swap the content into the canvas + projection_vert_->canvas()->addLayer(tmp); + projection_vert_->canvas()->setDrawMode(previous_mode); + } grid_->setRowStretch(0,2); projection_vert_->show(); projection_box_->show();