Loading...
Searching...
No Matches
integrationscopebase.h
Go to the documentation of this file.
// Copyright 2021 Filippo Rusconi
// GPLv3+
#pragma once
/////////////////////// StdLib includes
#include <vector>
#include <limits>
/////////////////////// Qt includes
#include <QObject>
#include <QString>
#include <QPointF>
/////////////////////// Local includes
#include "pappsomspp/export-import-config.h"
#include "../../types.h"
namespace pappso
{
/*
Bitwise stuff (from StackOverflow)
It is sometimes worth using an enum to name the bits:
enum ThingFlags = {
ThingMask = 0x0000,
ThingFlag0 = 1 << 0,
ThingFlag1 = 1 << 1,
ThingError = 1 << 8,
}
Then use the names later on. I.e. write
thingstate |= ThingFlag1;
thingstate &= ~ThingFlag0;
if (thing & ThingError) {...}
to set, clear and test. This way you hide the magic numbers from the rest of
your code.
*/
enum IntegrationScopeFeatures
{
// This one needs to be 0 because of (if!<function>() syntax)
FAILURE = 0x0000,
// As soon as not 0, success and potentially with more info.
SUCCESS = 1 << 1,
FLAT_ON_X_AXIS = 1 << 2,
FLAT_ON_Y_AXIS = 1 << 3,
RHOMBOID_VERTICAL = 1 << 4,
RHOMBOID_HORIZONTAL = 1 << 5,
NOT_PRINTABLE = 1 << 6,
FLAT_ON_ANY_AXIS = (FLAT_ON_X_AXIS | FLAT_ON_Y_AXIS)
};
class PMSPP_LIB_DECL IntegrationScopeBase : public QObject
{
Q_OBJECT
public:
IntegrationScopeBase(QObject *parent_p = nullptr);
IntegrationScopeBase(const IntegrationScopeBase &other, QObject *parent_p = nullptr);
virtual ~IntegrationScopeBase();
virtual bool getPoint(QPointF &point) const;
virtual bool getPoints(std::vector<QPointF> &points) const;
virtual IntegrationScopeFeatures getLeftMostPoint(QPointF &point) const;
virtual IntegrationScopeFeatures getLeftMostPoints(std::vector<QPointF> &points) const;
virtual IntegrationScopeFeatures getLeftMostTopPoint(QPointF &point) const;
virtual IntegrationScopeFeatures getLeftMostBottomPoint(QPointF &point) const;
virtual IntegrationScopeFeatures getRightMostPoint(QPointF &point) const;
virtual IntegrationScopeFeatures getRightMostPoints(std::vector<QPointF> &points) const;
virtual IntegrationScopeFeatures getRightMostTopPoint(QPointF &point) const;
virtual IntegrationScopeFeatures getRightMostBottomPoint(QPointF &point) const;
virtual IntegrationScopeFeatures getTopMostPoint(QPointF &point) const;
virtual IntegrationScopeFeatures getTopMostPoints(std::vector<QPointF> &points) const;
virtual IntegrationScopeFeatures getBottomMostPoint(QPointF &point) const;
virtual IntegrationScopeFeatures getBottomMostPoints(std::vector<QPointF> &points) const;
virtual IntegrationScopeFeatures getRhombHorizontalSize(double &size) const;
virtual IntegrationScopeFeatures getRhombVerticalSize(double &size) const;
virtual IntegrationScopeFeatures getWidth(double &width) const;
virtual IntegrationScopeFeatures getHeight(double &height) const;
virtual bool range(Enums::Axis axis, double &start, double &end) const;
virtual void setDataKindX(Enums::DataKind data_kind);
virtual bool getDataKindX(Enums::DataKind &data_kind);
virtual void setDataKindY(Enums::DataKind data_kind);
virtual bool getDataKindY(Enums::DataKind &data_kind);
virtual bool is1D() const;
virtual bool is2D() const;
virtual bool isRectangle() const;
virtual bool isRhomboid() const;
virtual bool transpose();
virtual bool contains(const QPointF &point) const;
virtual QString toString() const;
virtual void reset();
};
typedef std::shared_ptr<IntegrationScopeBase> IntegrationScopeBaseSPtr;
typedef std::shared_ptr<const IntegrationScopeBase> IntegrationScopeBaseCstSPtr;
struct PMSPP_LIB_DECL IntegrationScopeSpec
{
IntegrationScopeBaseSPtr integrationScopeSPtr;
Enums::DataKind dataKind = Enums::DataKind::unset;
// NO specification of the axis because it is implicit that MZ is Y and the
// checked value is either DT or RT depending on dataKind.
IntegrationScopeSpec();
IntegrationScopeSpec(IntegrationScopeBaseSPtr integration_scope_sp,
Enums::DataKind data_kind)
: integrationScopeSPtr(integration_scope_sp), dataKind(data_kind)
{
}
IntegrationScopeSpec(const IntegrationScopeSpec &other)
: integrationScopeSPtr(other.integrationScopeSPtr), dataKind(other.dataKind)
{
}
IntegrationScopeSpec &
operator=(const IntegrationScopeSpec &other)
{
if(this == &other)
return *this;
integrationScopeSPtr = other.integrationScopeSPtr;
dataKind = other.dataKind;
return *this;
}
QString
toString() const
{
QString text = "Integration scope spec:";
text += integrationScopeSPtr->toString();
text += " - data kind: ";
if(dataKind == Enums::DataKind::dt)
text += "dt.";
else if(dataKind == Enums::DataKind::mz)
text += "m/z.";
else if(dataKind == Enums::DataKind::rt)
text += "rt.";
else
text += "unset.";
return text;
}
};
typedef std::shared_ptr<IntegrationScopeSpec> IntegrationScopeSpecSPtr;
typedef std::shared_ptr<const IntegrationScopeSpec> IntegrationScopeSpecCstSPtr;
} // namespace pappso
pappso::IntegrationScopeBase::is2D
virtual bool is2D() const
Definition integrationscopebase.cpp:185
pappso::IntegrationScopeBase::getBottomMostPoint
virtual IntegrationScopeFeatures getBottomMostPoint(QPointF &point) const
Definition integrationscopebase.cpp:113
pappso::IntegrationScopeBase::isRectangle
virtual bool isRectangle() const
Definition integrationscopebase.cpp:191
pappso::IntegrationScopeBase::range
virtual bool range(Enums::Axis axis, double &start, double &end) const
Definition integrationscopebase.cpp:149
pappso::IntegrationScopeBase::isRhomboid
virtual bool isRhomboid() const
Definition integrationscopebase.cpp:197
pappso::IntegrationScopeBase::setDataKindY
virtual void setDataKindY(Enums::DataKind data_kind)
Definition integrationscopebase.cpp:162
pappso::IntegrationScopeBase::getLeftMostPoints
virtual IntegrationScopeFeatures getLeftMostPoints(std::vector< QPointF > &points) const
Definition integrationscopebase.cpp:59
pappso::IntegrationScopeBase::getWidth
virtual IntegrationScopeFeatures getWidth(double &width) const
Definition integrationscopebase.cpp:125
pappso::IntegrationScopeBase::getLeftMostPoint
virtual IntegrationScopeFeatures getLeftMostPoint(QPointF &point) const
Definition integrationscopebase.cpp:53
pappso::IntegrationScopeBase::getHeight
virtual IntegrationScopeFeatures getHeight(double &height) const
Definition integrationscopebase.cpp:131
pappso::IntegrationScopeBase::contains
virtual bool contains(const QPointF &point) const
Definition integrationscopebase.cpp:209
pappso::IntegrationScopeBase::getRightMostTopPoint
virtual IntegrationScopeFeatures getRightMostTopPoint(QPointF &point) const
Definition integrationscopebase.cpp:89
pappso::IntegrationScopeBase::getRightMostPoint
virtual IntegrationScopeFeatures getRightMostPoint(QPointF &point) const
Definition integrationscopebase.cpp:77
pappso::IntegrationScopeBase::toString
virtual QString toString() const
Definition integrationscopebase.cpp:215
pappso::IntegrationScopeBase::getBottomMostPoints
virtual IntegrationScopeFeatures getBottomMostPoints(std::vector< QPointF > &points) const
Definition integrationscopebase.cpp:119
pappso::IntegrationScopeBase::getTopMostPoint
virtual IntegrationScopeFeatures getTopMostPoint(QPointF &point) const
Definition integrationscopebase.cpp:101
pappso::IntegrationScopeBase::setDataKindX
virtual void setDataKindX(Enums::DataKind data_kind)
Definition integrationscopebase.cpp:157
pappso::IntegrationScopeBase::reset
virtual void reset()
Definition integrationscopebase.cpp:221
pappso::IntegrationScopeBase::getDataKindX
virtual bool getDataKindX(Enums::DataKind &data_kind)
Definition integrationscopebase.cpp:167
pappso::IntegrationScopeBase::getPoints
virtual bool getPoints(std::vector< QPointF > &points) const
Definition integrationscopebase.cpp:47
pappso::IntegrationScopeBase::getDataKindY
virtual bool getDataKindY(Enums::DataKind &data_kind)
Definition integrationscopebase.cpp:173
pappso::IntegrationScopeBase::getRightMostBottomPoint
virtual IntegrationScopeFeatures getRightMostBottomPoint(QPointF &point) const
Definition integrationscopebase.cpp:95
pappso::IntegrationScopeBase::getRhombHorizontalSize
virtual IntegrationScopeFeatures getRhombHorizontalSize(double &size) const
Definition integrationscopebase.cpp:137
pappso::IntegrationScopeBase::getLeftMostBottomPoint
virtual IntegrationScopeFeatures getLeftMostBottomPoint(QPointF &point) const
Definition integrationscopebase.cpp:71
pappso::IntegrationScopeBase::getRhombVerticalSize
virtual IntegrationScopeFeatures getRhombVerticalSize(double &size) const
Definition integrationscopebase.cpp:143
pappso::IntegrationScopeBase::getRightMostPoints
virtual IntegrationScopeFeatures getRightMostPoints(std::vector< QPointF > &points) const
Definition integrationscopebase.cpp:83
pappso::IntegrationScopeBase::getTopMostPoints
virtual IntegrationScopeFeatures getTopMostPoints(std::vector< QPointF > &points) const
Definition integrationscopebase.cpp:107
pappso::IntegrationScopeBase::getPoint
virtual bool getPoint(QPointF &point) const
Definition integrationscopebase.cpp:41
pappso::IntegrationScopeBase::IntegrationScopeBase
IntegrationScopeBase(QObject *parent_p=nullptr)
Definition integrationscopebase.cpp:21
pappso::IntegrationScopeBase::is1D
virtual bool is1D() const
Definition integrationscopebase.cpp:179
pappso::IntegrationScopeBase::getLeftMostTopPoint
virtual IntegrationScopeFeatures getLeftMostTopPoint(QPointF &point) const
Definition integrationscopebase.cpp:65
pappso::IntegrationScopeBase::transpose
virtual bool transpose()
Definition integrationscopebase.cpp:203
export-import-config.h
PMSPP_LIB_DECL
#define PMSPP_LIB_DECL
Definition export-import-config.h:14
pappso::Enums::DataKind
DataKind
Definition types.h:249
pappso::Enums::DataKind::dt
@ dt
Drift time.
Definition types.h:252
pappso::Enums::DataKind::mz
@ mz
m/z
Definition types.h:253
pappso::Enums::DataKind::rt
@ rt
Retention time.
Definition types.h:251
pappso::Enums::DataKind::unset
@ unset
not set
Definition types.h:250
pappso::Enums::Axis
Axis
Definition types.h:258
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::IntegrationScopeSpecCstSPtr
std::shared_ptr< const IntegrationScopeSpec > IntegrationScopeSpecCstSPtr
Definition integrationscopebase.h:176
pappso::IntegrationScopeBaseSPtr
std::shared_ptr< IntegrationScopeBase > IntegrationScopeBaseSPtr
Definition integrationscopebase.h:116
pappso::IntegrationScopeFeatures
IntegrationScopeFeatures
Definition integrationscopebase.h:47
pappso::SUCCESS
@ SUCCESS
Definition integrationscopebase.h:51
pappso::FLAT_ON_X_AXIS
@ FLAT_ON_X_AXIS
Definition integrationscopebase.h:52
pappso::FAILURE
@ FAILURE
Definition integrationscopebase.h:49
pappso::RHOMBOID_VERTICAL
@ RHOMBOID_VERTICAL
Definition integrationscopebase.h:54
pappso::RHOMBOID_HORIZONTAL
@ RHOMBOID_HORIZONTAL
Definition integrationscopebase.h:55
pappso::NOT_PRINTABLE
@ NOT_PRINTABLE
Definition integrationscopebase.h:56
pappso::FLAT_ON_Y_AXIS
@ FLAT_ON_Y_AXIS
Definition integrationscopebase.h:53
pappso::FLAT_ON_ANY_AXIS
@ FLAT_ON_ANY_AXIS
Definition integrationscopebase.h:57
pappso::IntegrationScopeSpecSPtr
std::shared_ptr< IntegrationScopeSpec > IntegrationScopeSpecSPtr
Definition integrationscopebase.h:175
pappso::IntegrationScopeBaseCstSPtr
std::shared_ptr< const IntegrationScopeBase > IntegrationScopeBaseCstSPtr
Definition integrationscopebase.h:117
pappso::IntegrationScopeSpec
Definition integrationscopebase.h:121
pappso::IntegrationScopeSpec::IntegrationScopeSpec
IntegrationScopeSpec()
pappso::IntegrationScopeSpec::operator=
IntegrationScopeSpec & operator=(const IntegrationScopeSpec &other)
Definition integrationscopebase.h:143
pappso::IntegrationScopeSpec::toString
QString toString() const
Definition integrationscopebase.h:155
pappso::IntegrationScopeSpec::IntegrationScopeSpec
IntegrationScopeSpec(const IntegrationScopeSpec &other)
Definition integrationscopebase.h:137
pappso::IntegrationScopeSpec::integrationScopeSPtr
IntegrationScopeBaseSPtr integrationScopeSPtr
Definition integrationscopebase.h:123
pappso::IntegrationScopeSpec::dataKind
Enums::DataKind dataKind
Definition integrationscopebase.h:124
pappso::IntegrationScopeSpec::IntegrationScopeSpec
IntegrationScopeSpec(IntegrationScopeBaseSPtr integration_scope_sp, Enums::DataKind data_kind)
Definition integrationscopebase.h:131
types.h