Loading...
Searching...
No Matches
integrationscoperect.cpp
Go to the documentation of this file.
// Copyright 2021 Filippo Rusconi
// GPLv3+
/////////////////////// StdLib includes
#include <cmath>
/////////////////////// Qt includes
#include <QDebug>
/////////////////////// Local includes
#include "integrationscoperect.h"
namespace pappso
{
IntegrationScopeRect::IntegrationScopeRect() : IntegrationScope()
{
// qDebug() << "Constructing" << this;
}
IntegrationScopeRect::IntegrationScopeRect(const QPointF &point, double width, double height)
: IntegrationScope(point, width), m_height(height)
{
// qDebug() << "Constructing" << this << "point:" << point << "width:" << width
// << "height:" << height;
}
IntegrationScopeRect::IntegrationScopeRect(const QPointF &point,
double width,
Enums::DataKind data_kind_x,
double height,
Enums::DataKind data_kind_y)
: IntegrationScope(point, width, data_kind_x), m_height(height), m_dataKindY(data_kind_y)
{
// qDebug() << "Constructing" << this << "point:" << point << "width:" << width
// << "height:" << height
// << "data_kind_x:" << static_cast<int>(data_kind_x)
// << "data_kind_y:" << static_cast<int>(data_kind_y);
}
IntegrationScopeRect::IntegrationScopeRect(const IntegrationScopeRect &other)
: IntegrationScope(other.m_point, other.m_width, other.m_dataKindX),
m_height(other.m_height),
m_dataKindY(other.m_dataKindY)
{
// qDebug() << "Constructing" << this << "point:" << point << "width:" << width
// << "height:" << height
// << "data_kind_x:" << static_cast<int>(data_kind_x)
// << "data_kind_y:" << static_cast<int>(data_kind_y);
}
IntegrationScopeRect::~IntegrationScopeRect()
{
// qDebug() << "Destructing" << this;
}
IntegrationScopeRect &
IntegrationScopeRect::operator=(const IntegrationScopeRect &other)
{
if(this == &other)
return *this;
IntegrationScope::operator=(other);
m_height = other.m_height;
m_dataKindX = other.m_dataKindX;
m_dataKindY = other.m_dataKindY;
return *this;
}
IntegrationScopeFeatures
IntegrationScopeRect::getTopMostPoint(QPointF &point) const
{
point = QPointF(m_point.x(), m_point.y() + m_height);
return IntegrationScopeFeatures::SUCCESS;
}
IntegrationScopeFeatures
IntegrationScopeRect::getBottomMostPoint(QPointF &point) const
{
point = m_point;
return IntegrationScopeFeatures::SUCCESS;
}
void
IntegrationScopeRect::setHeight(double height)
{
m_height = height;
}
IntegrationScopeFeatures
IntegrationScopeRect::getHeight(double &height) const
{
height = m_height;
return IntegrationScopeFeatures::SUCCESS;
}
bool
IntegrationScopeRect::range(Enums::Axis axis, double &start, double &end) const
{
if(axis == Enums::Axis::x)
{
start = m_point.x();
end = start + m_width;
return true;
}
else if(axis == Enums::Axis::y)
{
start = m_point.y();
end = start + m_height;
return true;
}
return false;
}
void
IntegrationScopeRect::setDataKindX([[maybe_unused]] Enums::DataKind data_kind)
{
m_dataKindX = data_kind;
}
void
IntegrationScopeRect::setDataKindY([[maybe_unused]] Enums::DataKind data_kind)
{
m_dataKindY = data_kind;
}
bool
IntegrationScopeRect::getDataKindX([[maybe_unused]] Enums::DataKind &data_kind)
{
data_kind = m_dataKindX;
return true;
}
bool
IntegrationScopeRect::getDataKindY([[maybe_unused]] Enums::DataKind &data_kind)
{
data_kind = m_dataKindY;
return true;
}
bool
IntegrationScopeRect::is1D() const
{
return false;
}
bool
IntegrationScopeRect::is2D() const
{
return !is1D();
}
bool
IntegrationScopeRect::isRectangle() const
{
return true;
}
bool
IntegrationScopeRect::isRhomboid() const
{
return false;
}
bool
IntegrationScopeRect::transpose()
{
Enums::DataKind was_data_kind_y = m_dataKindY;
m_dataKindY = m_dataKindX;
m_dataKindX = was_data_kind_y;
// qDebug() << "Point before rectangle transposition:" << m_point;
// Transpose the point.
QPointF transposed_point(m_point.y(), m_point.x());
m_point = transposed_point;
// qDebug() << "Point after rectangle transposition:" << m_point;
// qDebug() << "Before transposition: width is" << m_width << "and height is"
// << m_height;
// Tranpose width <--> height
double was_height = m_height;
m_height = m_width;
m_width = was_height;
// qDebug() << "After transposition: width is" << m_width << "and height is"
// << m_height;
return true;
}
void
IntegrationScopeRect::update(const QPointF &point, double width, double height)
{
IntegrationScope::m_point = point;
IntegrationScope::m_width = width;
m_height = height;
}
bool
IntegrationScopeRect::contains(const QPointF &point) const
{
return (point.x() >= m_point.x() && point.x() <= m_point.x() + m_width &&
point.y() >= m_point.y() && point.y() <= m_point.y() + m_height);
}
QString
IntegrationScopeRect::toString() const
{
QString text = "[";
text.append(QString("(%1, %2)").arg(m_point.x(), 0, 'f', 3).arg(m_point.y(), 0, 'f', 3));
text.append("->");
text.append(QString("(%1, %2)")
.arg(m_point.x() + m_width, 0, 'f', 3)
.arg(m_point.y() + m_height, 0, 'f', 3));
text.append("]");
return text;
}
void
IntegrationScopeRect::reset()
{
IntegrationScope::reset();
m_height = 0;
}
} // namespace pappso
pappso::IntegrationScopeRect
Definition integrationscoperect.h:45
pappso::IntegrationScopeRect::getBottomMostPoint
virtual IntegrationScopeFeatures getBottomMostPoint(QPointF &point) const override
Definition integrationscoperect.cpp:86
pappso::IntegrationScopeRect::update
virtual void update(const QPointF &point, double width, double height)
Definition integrationscoperect.cpp:206
pappso::IntegrationScopeRect::operator=
virtual IntegrationScopeRect & operator=(const IntegrationScopeRect &other)
Definition integrationscoperect.cpp:63
pappso::IntegrationScopeRect::m_dataKindY
Enums::DataKind m_dataKindY
Definition integrationscoperect.h:90
pappso::IntegrationScopeRect::m_height
double m_height
Definition integrationscoperect.h:89
pappso::IntegrationScopeRect::isRectangle
virtual bool isRectangle() const override
Definition integrationscoperect.cpp:165
pappso::IntegrationScopeRect::IntegrationScopeRect
IntegrationScopeRect()
Definition integrationscoperect.cpp:20
pappso::IntegrationScopeRect::getHeight
virtual IntegrationScopeFeatures getHeight(double &height) const override
Definition integrationscoperect.cpp:99
pappso::IntegrationScopeRect::toString
virtual QString toString() const override
Definition integrationscoperect.cpp:221
pappso::IntegrationScopeRect::transpose
virtual bool transpose() override
Definition integrationscoperect.cpp:177
pappso::IntegrationScopeRect::setDataKindY
virtual void setDataKindY(Enums::DataKind data_kind) override
Definition integrationscoperect.cpp:133
pappso::IntegrationScopeRect::setDataKindX
virtual void setDataKindX(Enums::DataKind data_kind) override
Definition integrationscoperect.cpp:127
pappso::IntegrationScopeRect::getDataKindX
virtual bool getDataKindX(Enums::DataKind &data_kind) override
Definition integrationscoperect.cpp:139
pappso::IntegrationScopeRect::is2D
bool is2D() const override
Definition integrationscoperect.cpp:159
pappso::IntegrationScopeRect::range
virtual bool range(Enums::Axis axis, double &start, double &end) const override
Definition integrationscoperect.cpp:106
pappso::IntegrationScopeRect::getTopMostPoint
virtual IntegrationScopeFeatures getTopMostPoint(QPointF &point) const override
Definition integrationscoperect.cpp:79
pappso::IntegrationScopeRect::getDataKindY
virtual bool getDataKindY(Enums::DataKind &data_kind) override
Definition integrationscoperect.cpp:146
pappso::IntegrationScopeRect::setHeight
virtual void setHeight(double height)
Definition integrationscoperect.cpp:93
pappso::IntegrationScopeRect::contains
virtual bool contains(const QPointF &point) const override
Definition integrationscoperect.cpp:214
pappso::IntegrationScopeRect::isRhomboid
virtual bool isRhomboid() const override
Definition integrationscoperect.cpp:171
pappso::IntegrationScopeRect::is1D
bool is1D() const override
Definition integrationscoperect.cpp:153
pappso::IntegrationScopeRect::~IntegrationScopeRect
virtual ~IntegrationScopeRect()
Definition integrationscoperect.cpp:57
pappso::IntegrationScopeRect::reset
virtual void reset() override
Definition integrationscoperect.cpp:239
pappso::IntegrationScope::m_dataKindX
Enums::DataKind m_dataKindX
Definition integrationscope.h:94
pappso::IntegrationScope::point
QPointF point
Definition integrationscope.h:39
pappso::IntegrationScope::m_width
double m_width
Definition integrationscope.h:93
pappso::IntegrationScope::m_point
QPointF m_point
Definition integrationscope.h:92
pappso::IntegrationScope::operator=
virtual IntegrationScope & operator=(const IntegrationScope &other)
Definition integrationscope.cpp:62
pappso::IntegrationScope::IntegrationScope
WRITE setPoint() NOTIFY pointChanged() FINAL) Q_PROPERTY(double width READ getWidth() WRITE setWidth() NOTIFY widthChanged() FINAL) public IntegrationScope(const QPointF &point, double width, QObject *parent_p=nullptr)
Definition integrationscope.cpp:27
pappso::IntegrationScope::reset
virtual void reset() override
Definition integrationscope.cpp:205
integrationscoperect.h
pappso::Enums::DataKind
DataKind
Definition types.h:249
pappso::Enums::Axis
Axis
Definition types.h:258
pappso::Enums::Axis::y
@ y
Definition types.h:261
pappso::Enums::Axis::x
@ x
Definition types.h:260
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::IntegrationScopeFeatures
IntegrationScopeFeatures
Definition integrationscopebase.h:47
pappso::SUCCESS
@ SUCCESS
Definition integrationscopebase.h:51