Loading...
Searching...
No Matches
datapointjs.cpp
Go to the documentation of this file.
#include "datapointjs.h"
#include "jsclassregistrar.h"
namespace pappso
{
DataPointJs::DataPointJs(QObject *parent) : QObject(parent), m_dataPoint()
{
}
DataPointJs::DataPointJs(double x, double y, QObject *parent) : QObject(parent), m_dataPoint(x, y)
{
}
DataPointJs::DataPointJs(const DataPoint &data_ppoint, QObject *parent)
: QObject(parent), m_dataPoint(data_ppoint)
{
}
void
DataPointJs::setX(double x)
{
if(m_dataPoint.x != x)
{
m_dataPoint.x = x;
emit xChanged();
emit stringChanged();
emit validChanged();
}
}
double
DataPointJs::getX() const
{
return m_dataPoint.x;
}
void
DataPointJs::setY(double y)
{
if(m_dataPoint.y != y)
{
m_dataPoint.y = y;
emit yChanged();
emit stringChanged();
emit validChanged();
}
}
double
DataPointJs::getY() const
{
return m_dataPoint.y;
}
void
DataPointJs::setData(double x, double y)
{
setX(x);
setY(y);
}
bool
DataPointJs::isValid() const
{
return m_dataPoint.isValid();
}
QString
DataPointJs::toString() const
{
return m_dataPoint.toString();
}
QString
DataPointJs::toString(int decimals) const
{
return m_dataPoint.toString(decimals);
}
void
DataPointJs::reset()
{
m_dataPoint.reset();
emit xChanged();
emit yChanged();
emit stringChanged();
emit validChanged();
}
void
DataPointJs::incrementX(double value)
{
m_dataPoint.incrementX(value);
emit xChanged();
emit stringChanged();
}
void
DataPointJs::incrementY(double value)
{
m_dataPoint.incrementY(value);
emit yChanged();
emit stringChanged();
}
void
DataPointJs::initialize(double x, double y)
{
m_dataPoint.initialize(x, y);
emit xChanged();
emit yChanged();
emit validChanged();
emit stringChanged();
}
void
DataPointJs::initialize(const QString &text)
{
if(m_dataPoint.initialize(text))
{
emit xChanged();
emit yChanged();
emit validChanged();
emit stringChanged();
}
}
const DataPoint &
DataPointJs::dataPoint() const
{
return m_dataPoint;
}
void
DataPointJs::setDataPoint(const DataPoint &point)
{
m_dataPoint = point;
emit xChanged();
emit yChanged();
emit validChanged();
emit stringChanged();
}
void
DataPointJs::registerJsConstructor(QJSEngine *engine)
{
if(!engine)
{
qWarning() << "Cannot register DataPointJs class: engine is null";
return;
}
// Register the meta object as a constructor
QJSValue jsMetaObject = engine->newQMetaObject(&DataPointJs::staticMetaObject);
engine->globalObject().setProperty("DataPoint", jsMetaObject);
}
} // namespace pappso
pappso::DataPointJs::validChanged
void validChanged()
pappso::DataPointJs::getX
Q_INVOKABLE double getX() const
Definition datapointjs.cpp:34
pappso::DataPointJs::toString
QString toString() const
Definition datapointjs.cpp:72
pappso::DataPointJs::yChanged
void yChanged()
pappso::DataPointJs::reset
Q_INVOKABLE void reset()
Definition datapointjs.cpp:84
pappso::DataPointJs::setX
Q_INVOKABLE void setX(double x)
Definition datapointjs.cpp:22
pappso::DataPointJs::setY
Q_INVOKABLE void setY(double y)
Definition datapointjs.cpp:41
pappso::DataPointJs::setDataPoint
void setDataPoint(const DataPoint &point)
Definition datapointjs.cpp:138
pappso::DataPointJs::DataPointJs
Q_INVOKABLE DataPointJs(QObject *parent=nullptr)
Definition datapointjs.cpp:8
pappso::DataPointJs::stringChanged
void stringChanged()
pappso::DataPointJs::dataPoint
const DataPoint & dataPoint() const
Definition datapointjs.cpp:132
pappso::DataPointJs::setData
Q_INVOKABLE void setData(double x, double y)
Definition datapointjs.cpp:59
pappso::DataPointJs::m_dataPoint
DataPoint m_dataPoint
Definition datapointjs.h:70
pappso::DataPointJs::y
double y
Definition datapointjs.h:29
pappso::DataPointJs::incrementY
Q_INVOKABLE void incrementY(double value)
Definition datapointjs.cpp:102
pappso::DataPointJs::incrementX
Q_INVOKABLE void incrementX(double value)
Definition datapointjs.cpp:94
pappso::DataPointJs::xChanged
void xChanged()
pappso::DataPointJs::getY
Q_INVOKABLE double getY() const
Definition datapointjs.cpp:53
pappso::DataPointJs::registerJsConstructor
static void registerJsConstructor(QJSEngine *engine)
Definition datapointjs.cpp:148
pappso::DataPointJs::x
double x
Definition datapointjs.h:28
pappso::DataPointJs::isValid
bool isValid() const
Definition datapointjs.cpp:66
pappso::DataPointJs::initialize
Q_INVOKABLE void initialize(double x, double y)
Definition datapointjs.cpp:110
datapointjs.h
jsclassregistrar.h
pappso
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition aa.cpp:39
pappso::DataPoint
Definition datapoint.h:22