Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions doc/code_examples/Tutorial_GUI_Plot1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,36 @@
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

#include <QApplication>
#include <OpenMS/VISUAL/Plot1DWidget.h>
#include <OpenMS/FORMAT/DTAFile.h>
#include <OpenMS/KERNEL/StandardTypes.h>
#include <OpenMS/KERNEL/OnDiscMSExperiment.h>
#include <OpenMS/KERNEL/StandardTypes.h>
#include <OpenMS/VISUAL/LayerDataBase.h>
#include <OpenMS/VISUAL/Plot1DWidget.h>
#include <OpenMS/VISUAL/Plot2DWidget.h>
#include <OpenMS/openms_data_path.h>
#include <QApplication>

using namespace OpenMS;
using namespace std;

Int main(int argc, const char ** argv)
Int main(int argc, const char** argv)
{
if (argc < 2) return 1;
// the path to the data should be given on the command line
String tutorial_data_path(argv[1]);

QApplication app(argc, const_cast<char **>(argv));
String tutorial_data_path(OPENMS_DOC_PATH + String("/code_examples/data/Tutorial_Spectrum1D.dta"));
if (argc >= 2)
{ // the path to the data can be given on the command line
tutorial_data_path = argv[1];
}

QApplication app(argc, const_cast<char**>(argv));

PeakMap exp;
exp.resize(1);
DTAFile().load(tutorial_data_path + "/data/Tutorial_Spectrum1D.dta", exp[0]);
DTAFile().load(tutorial_data_path, exp[0]);
LayerDataBase::ExperimentSharedPtrType exp_sptr(new PeakMap(exp));
LayerDataBase::ODExperimentSharedPtrType on_disc_exp_sptr(new OnDiscMSExperiment());
Plot1DWidget * widget = new Plot1DWidget(Param(), nullptr);
auto* widget = new Plot1DWidget(Param(), nullptr);
widget->canvas()->addLayer(exp_sptr, on_disc_exp_sptr);
widget->show();

return app.exec();
} //end of main
} // end of main
5 changes: 2 additions & 3 deletions src/openms/include/OpenMS/FORMAT/HANDLERS/XMLHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,20 @@
#include <OpenMS/DATASTRUCTURES/ListUtils.h> // StringList
#include <OpenMS/DATASTRUCTURES/DateTime.h>
#include <OpenMS/DATASTRUCTURES/ListUtils.h>
#include <OpenMS/METADATA/MetaInfoInterface.h>

#include <xercesc/util/XMLString.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
#include <xercesc/sax/Locator.hpp>
#include <xercesc/sax2/Attributes.hpp>

#include <iosfwd>
#include <string>
#include <memory>


namespace OpenMS
{
class ProteinIdentification;

class MetaInfoInterface;

namespace Internal
{
Expand Down
1 change: 1 addition & 0 deletions src/openms/source/FORMAT/CVMappingFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <OpenMS/FORMAT/CVMappingFile.h>
#include <OpenMS/DATASTRUCTURES/CVReference.h>
#include <OpenMS/DATASTRUCTURES/CVMappingTerm.h>
#include <OpenMS/DATASTRUCTURES/DataValue.h>
#include <OpenMS/SYSTEM/File.h>

using namespace xercesc;
Expand Down
3 changes: 2 additions & 1 deletion src/openms/source/FORMAT/ControlledVocabulary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@

#include <OpenMS/FORMAT/ControlledVocabulary.h>

#include <OpenMS/SYSTEM/File.h>
#include <OpenMS/DATASTRUCTURES/DataValue.h>
#include <OpenMS/FORMAT/HANDLERS/XMLHandler.h>
#include <OpenMS/SYSTEM/File.h>

#include <iostream>
#include <fstream>
Expand Down
14 changes: 9 additions & 5 deletions src/openms_gui/include/OpenMS/VISUAL/LayerDataBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <OpenMS/METADATA/PeptideIdentification.h>
#include <OpenMS/METADATA/ProteinIdentification.h>
#include <OpenMS/VISUAL/ANNOTATION/Annotations1DContainer.h>
//#include <OpenMS/VISUAL/Painter1DBase.h>
#include <OpenMS/VISUAL/LogWindow.h>
#include <OpenMS/VISUAL/MultiGradient.h>

Expand All @@ -64,6 +65,7 @@ namespace OpenMS
class LayerStatistics;
class OnDiscMSExperiment;
class OSWData;
class Painter1DBase;

/**
@brief Class that stores the data for one layer
Expand Down Expand Up @@ -171,19 +173,21 @@ namespace OpenMS

/// Default constructor
LayerDataBase() = delete;
/// Ctor for child classes
/// C'tor for child classes
LayerDataBase(const DataType type) : type(type) {};
/// no Copy-ctor (should not be needed)
LayerDataBase(const LayerDataBase& ld) = delete;
/// no assignment operator (should not be needed)
LayerDataBase& operator=(const LayerDataBase& ld) = delete;
/// move Ctor
/// move C'tor
LayerDataBase(LayerDataBase&& ld) = default;
/// move assignment
LayerDataBase& operator=(LayerDataBase&& ld) = default;
/// Dtor
/// D'tor
virtual ~LayerDataBase() = default;

virtual std::unique_ptr<Painter1DBase> getPainter1D() const = 0;


/// Returns a const reference to the current feature data
const FeatureMapSharedPtrType& getFeatureMap() const
Expand Down Expand Up @@ -267,11 +271,11 @@ namespace OpenMS
return chromatogram_map_;
}

/// get annotation (e.g. to build a hierachical ID View)
/// get annotation (e.g. to build a hierarchical ID View)
/// Not const, because we might have incomplete data, which needs to be loaded from sql source
OSWDataSharedPtrType& getChromatogramAnnotation();

/// get annotation (e.g. to build a hierachical ID View)
/// get annotation (e.g. to build a hierarchical ID View)
/// Not actually const (only the pointer, not the data), because we might have incomplete data, which needs to be loaded from sql source
const OSWDataSharedPtrType& getChromatogramAnnotation() const;

Expand Down
4 changes: 3 additions & 1 deletion src/openms_gui/include/OpenMS/VISUAL/LayerDataChrom.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ namespace OpenMS
LayerDataChrom(const LayerDataChrom& ld) = delete;
/// no assignment operator (should not be needed)
LayerDataChrom& operator=(const LayerDataChrom& ld) = delete;
/// move Ctor
/// move C'tor
LayerDataChrom(LayerDataChrom&& ld) = default;
/// move assignment
LayerDataChrom& operator=(LayerDataChrom&& ld) = default;

std::unique_ptr<Painter1DBase> getPainter1D() const override;

void updateRanges() override
{
peak_map_->updateRanges();
Expand Down
2 changes: 2 additions & 0 deletions src/openms_gui/include/OpenMS/VISUAL/LayerDataConsensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace OpenMS
/// move assignment
LayerDataConsensus& operator=(LayerDataConsensus&& ld) = default;

std::unique_ptr<Painter1DBase> getPainter1D() const override;

void updateRanges() override
{
consensus_map_->updateRanges();
Expand Down
4 changes: 3 additions & 1 deletion src/openms_gui/include/OpenMS/VISUAL/LayerDataFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ namespace OpenMS
LayerDataFeature(const LayerDataFeature& ld) = delete;
/// no assignment operator (should not be needed)
LayerDataFeature& operator=(const LayerDataFeature& ld) = delete;
/// move Ctor
/// move C'tor
LayerDataFeature(LayerDataFeature&& ld) = default;
/// move assignment
LayerDataFeature& operator=(LayerDataFeature&& ld) = default;

std::unique_ptr<Painter1DBase> getPainter1D() const override;

void updateRanges() override
{
features_->updateRanges();
Expand Down
2 changes: 2 additions & 0 deletions src/openms_gui/include/OpenMS/VISUAL/LayerDataIdent.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ namespace OpenMS
/// move assignment
LayerDataIdent& operator=(LayerDataIdent&& ld) = default;

std::unique_ptr<Painter1DBase> getPainter1D() const override;

void updateRanges() override
{
// nothing to do...
Expand Down
2 changes: 2 additions & 0 deletions src/openms_gui/include/OpenMS/VISUAL/LayerDataPeak.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ namespace OpenMS
/// move assignment
LayerDataPeak& operator=(LayerDataPeak&& ld) = default;

std::unique_ptr<Painter1DBase> getPainter1D() const override;

void updateRanges() override
{
peak_map_->updateRanges();
Expand Down
88 changes: 88 additions & 0 deletions src/openms_gui/include/OpenMS/VISUAL/Painter1DBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// --------------------------------------------------------------------------
// OpenMS -- Open-Source Mass Spectrometry
// --------------------------------------------------------------------------
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
// ETH Zurich, and Freie Universitaet Berlin 2002-2021.
//
// This software is released under a three-clause BSD license:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of any author or any participating institution
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
// For a full list of authors, refer to the file AUTHORS.
// --------------------------------------------------------------------------
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// --------------------------------------------------------------------------
// $Maintainer: Chris Bielow $
// $Authors: Chris Bielow $
// --------------------------------------------------------------------------

#pragma once

#include <OpenMS/VISUAL/LayerDataBase.h>

class QPainter;
class QPenStyle;

namespace OpenMS
{
class LayerDataPeak;
class Plot1DCanvas;

/**
* @brief A base class for painting all items from a data layer (as supported by class derived from here) onto a 1D Canvas
*/
class OPENMS_GUI_DLLAPI Painter1DBase
{
public:
/**
@brief Paints items using the given painter onto the canvas.

@param painter The painter used for drawing
@param canvas The canvas to paint onto (should expose all the details needed, like canvas size, draw mode, colors etc)
@param layer_index Which layer is currently painted (FIXME: remove when Canvas1D::DrawMode and PenStyle are factored out)
*/
virtual void paint(QPainter*, Plot1DCanvas* canvas, int layer_index) = 0;

/// static method to draw a dashed line
static void drawDashedLine(const QPoint& from, const QPoint& to, QPainter* painter, QColor color);
};

/**
@brief Painter1D for spectra

*/
class OPENMS_GUI_DLLAPI Painter1DPeak : public Painter1DBase
{
public:
/// C'tor which remembers the layer to paint
Painter1DPeak(const LayerDataPeak* parent);

/// Implementation of base class
void paint(QPainter*, Plot1DCanvas* canvas, int layer_index) override;

protected:
/// draw all Annotation1DItems attached to the layer
void drawAnnotations_(QPainter& painter, Plot1DCanvas* canvas);
/// annotate up to 10 interesting peaks in the range @p vbegin to @pvend with their m/z values (using deisotoping and intensity filtering)
void drawMZAtInterestingPeaks_(QPainter& painter, Plot1DCanvas* canvas, MSSpectrum::ConstIterator vbegin, MSSpectrum::ConstIterator vend);

const LayerDataPeak* layer_; ///< the data to paint
};

} // namespace OpenMS
22 changes: 9 additions & 13 deletions src/openms_gui/include/OpenMS/VISUAL/Plot1DCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@

// OpenMS
#include <OpenMS/VISUAL/PlotCanvas.h>
#include <OpenMS/VISUAL/Painter1DBase.h>

// QT
#include <QTextDocument>

// STL
Expand All @@ -51,6 +53,7 @@ class QAction;

namespace OpenMS
{

/**
@brief Canvas for visualization of one or several spectra.

Expand Down Expand Up @@ -157,20 +160,13 @@ namespace OpenMS
/// Add an annotation item for the given peak
Annotation1DItem* addPeakAnnotation(const PeakIndex& peak_index, const QString& text, const QColor& color);

/// Draws all annotation items of @p layer_index on @p painter
void drawAnnotations(Size layer_index, QPainter& painter);

/// ----- Alignment

/// Performs an alignment of the layers with @p layer_index_1 and @p layer_index_2
void performAlignment(Size layer_index_1, Size layer_index_2, const Param& param);

/// Resets alignment_
void resetAlignment();

/// Draws the alignment on @p painter
void drawAlignment(QPainter& painter);

/// Returns the number of aligned pairs of peaks
Size getAlignmentSize();

Expand Down Expand Up @@ -248,9 +244,9 @@ protected slots:
void drawCoordinates_(QPainter& painter, const PeakIndex& peak);
/// Draws the coordinates (or coordinate deltas) to the widget's upper left corner
void drawDeltas_(QPainter& painter, const PeakIndex& start, const PeakIndex& end);

/// annotate interesting peaks in visible area with m/z
void drawMZAtInterestingPeaks_(Size layer_index, QPainter& painter);
/// Draws the alignment on @p painter
void drawAlignment_(QPainter& painter);

/**
@brief Changes visible area interval
Expand All @@ -262,9 +258,6 @@ protected slots:
/// Draws a highlighted peak; if draw_elongation is true, the elongation line is drawn (for measuring)
void drawHighlightedPeak_(Size layer_index, const PeakIndex& peak, QPainter& painter, bool draw_elongation = false);

/// Draws a dashed line using the highlighted peak color parameter
void drawDashedLine_(const QPoint& from, const QPoint& to, QPainter& painter);

/// Recalculates the current scale factor based on the specified layer (= 1.0 if intensity mode != IM_PERCENTAGE)
void updatePercentageFactor_(Size layer_index);

Expand Down Expand Up @@ -353,6 +346,9 @@ protected slots:
void translateRight_(Qt::KeyboardModifiers m) override;
//docu in base class
void paintGridLines_(QPainter& painter) override;

friend class Painter1DPeak;

};
} // namespace OpenMS

1 change: 1 addition & 0 deletions src/openms_gui/include/OpenMS/VISUAL/sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ MetaDataBrowser.h
MultiGradient.h
MultiGradientSelector.h
OutputDirectory.h
Painter1DBase.h
ParamEditor.h
Plot1DCanvas.h
Plot1DWidget.h
Expand Down
8 changes: 0 additions & 8 deletions src/openms_gui/source/VISUAL/LayerDataBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@ namespace OpenMS
}
}


/// add annotation from an OSW sqlite file.


/// get annotation (e.g. to build a hierachical ID View)
/// Not const, because we might have incomplete data, which needs to be loaded from sql source

LayerDataBase::OSWDataSharedPtrType& LayerDataBase::getChromatogramAnnotation()
{
return chrom_annotation_;
Expand Down Expand Up @@ -153,7 +146,6 @@ namespace OpenMS
return cached_spectrum_;
}

/// Returns a const-copy of the required spectrum which is guaranteed to be populated with raw data

const LayerDataBase::ExperimentType::SpectrumType LayerDataBase::getSpectrum(Size spectrum_idx) const
{
Expand Down
Loading