Loading...
Searching...
No Matches
pappso::TraceJs Class Reference

`#include <tracejs.h>`

Inheritance diagram for pappso::TraceJs:

## Signals

void | sizeChangedSignal ()

## Public Member Functions

Q_INVOKABLE | TraceJs (QObject *parent=nullptr)
Q_INVOKABLE | TraceJs (const Trace &trace, QObject *parent=nullptr)
TraceJs & | operator= (const TraceJs &)=delete
Q_INVOKABLE int | getSize () const
Q_INVOKABLE void | append (double x, double y)
Q_INVOKABLE void | append (const DataPointJs *data_point_js_p)
Q_INVOKABLE DataPointJs * | getPointAt (int index) const
Q_INVOKABLE QVariantList | getTrace () const
Q_INVOKABLE void | initialize (const QVariantList &js_points)
Q_INVOKABLE void | initialize (const QVariantMap &map)
Q_INVOKABLE std::size_t | initialize (const QVariantList &x_values, const QVariantList &y_values)
Q_INVOKABLE std::size_t | initialize (const QString &x_text, const QString &y_text)
Q_INVOKABLE std::size_t | initialize (const QString &space_sep_text)
Q_INVOKABLE std::size_t | initialize (const TraceJs &other)
Q_INVOKABLE QVariantList | xValues () const
Q_INVOKABLE QVariantList | yValues () const
Q_INVOKABLE QVariantMap | toMap () const
Q_INVOKABLE void | clear ()

## Static Public Member Functions

static void | registerJsConstructor (QJSEngine *engine)

## Properties

int | size

## Private Attributes

Trace | m_trace

## Detailed Description

Definition at line 26 of file tracejs.h.

## Constructor & Destructor Documentation

## TraceJs() [1/2]

pappso::TraceJs::TraceJs | ( | QObject * | parent = nullptr | ) |

explicit

Definition at line 9 of file tracejs.cpp.

: QObject(parent), m_trace()
{
}
pappso::TraceJs::m_trace
Trace m_trace
Definition tracejs.h:69

References m_trace.

Referenced by getPointAt(), getTrace(), initialize(), and operator=().

## TraceJs() [2/2]

pappso::TraceJs::TraceJs | ( | const Trace & | trace,
|  | QObject * | parent = nullptr )

explicit

Definition at line 13 of file tracejs.cpp.

: QObject(parent), m_trace(trace)
{
}

References m_trace.

## Member Function Documentation

## append() [1/2]

void pappso::TraceJs::append | ( | const DataPointJs * | data_point_js_p | ) |

Definition at line 31 of file tracejs.cpp.

{
if(data_point_js_p != nullptr)
{
m_trace.push_back(data_point_js_p->dataPoint());
emit sizeChangedSignal();
}
}
pappso::TraceJs::sizeChangedSignal
void sizeChangedSignal()

References pappso::DataPointJs::dataPoint(), m_trace, and sizeChangedSignal().

## append() [2/2]

void pappso::TraceJs::append | ( | double | x,
|  | double | y )

Definition at line 24 of file tracejs.cpp.

{
m_trace.push_back(DataPoint(x, y));
emit sizeChangedSignal();
}
pappso::PeptideIonCter::y
@ y
Definition peptide.h:87
pappso::PeptideIonCter::x
@ x
Definition peptide.h:92

References m_trace, sizeChangedSignal(), pappso::x, and pappso::y.

Referenced by operator=().

## clear()

void pappso::TraceJs::clear | ( |  | ) |

Definition at line 208 of file tracejs.cpp.

{
m_trace.clear();
}

References m_trace.

Referenced by operator=().

## getPointAt()

DataPointJs * pappso::TraceJs::getPointAt | ( | int | index | ) | const

Definition at line 41 of file tracejs.cpp.

{
if(index < 0 || index >= static_cast<int>(m_trace.size()))
{
return nullptr;
}
// Simple version: create wrapper on the fly
return new DataPointJs(m_trace[index], const_cast<TraceJs *>(this));
}
pappso::TraceJs::TraceJs
Q_INVOKABLE TraceJs(QObject *parent=nullptr)
Definition tracejs.cpp:9

References TraceJs(), and m_trace.

Referenced by operator=().

## getSize()

int pappso::TraceJs::getSize | ( |  | ) | const

Definition at line 18 of file tracejs.cpp.

{
return m_trace.size();
}

References m_trace.

Referenced by operator=().

## getTrace()

QVariantList pappso::TraceJs::getTrace | ( |  | ) | const

Definition at line 54 of file tracejs.cpp.

{
QVariantList list;
for(const DataPoint &data_point : m_trace)
{
DataPointJs *data_point_js_p = new DataPointJs(data_point, const_cast<TraceJs *>(this));
list.append(QVariant::fromValue(data_point_js_p));
}
return list;
}

References TraceJs(), and m_trace.

Referenced by operator=().

## initialize() [1/6]

size_t pappso::TraceJs::initialize | ( | const QString & | space_sep_text | ) |

Definition at line 143 of file tracejs.cpp.

{
m_trace.initialize(space_sep_text);
emit sizeChangedSignal();
return m_trace.size();
}

References m_trace, and sizeChangedSignal().

## initialize() [2/6]

size_t pappso::TraceJs::initialize | ( | const QString & | x_text,
|  | const QString & | y_text )

Definition at line 133 of file tracejs.cpp.

{
m_trace.initialize(x_text, y_text);
emit sizeChangedSignal();
return m_trace.size();
}

References m_trace, and sizeChangedSignal().

## initialize() [3/6]

void pappso::TraceJs::initialize | ( | const QVariantList & | js_points | ) |

Definition at line 68 of file tracejs.cpp.

{
m_trace.clear();
for(const QVariant &variant : js_points)
{
QObject *obj = variant.value<QObject *>();
// The cast returns nullptr if the variant did not
// convert to DataPointJs.
if(auto data_point_js = qobject_cast<DataPointJs *>(obj))
{
DataPoint data_point = data_point_js->dataPoint();
m_trace.push_back(data_point); // Extract the internal DataPoint
}
else
{
qWarning() << "Failed initializing Trace because list member is not a DataPointJs object:"
<< obj;
}
}
emit sizeChangedSignal();
}

References m_trace, and sizeChangedSignal().

Referenced by operator=().

## initialize() [4/6]

std::size_t pappso::TraceJs::initialize | ( | const QVariantList & | x_values,
|  | const QVariantList & | y_values )

Definition at line 116 of file tracejs.cpp.

{
if(x_values.size() != y_values.size())
qFatal() << "The two containers must have the same size.";
m_trace.clear();
m_trace.reserve(x_values.size());
for(int iter = 0; iter < x_values.size(); ++iter)
m_trace.push_back(DataPoint(x_values.at(iter).toDouble(), y_values.at(iter).toDouble()));
emit sizeChangedSignal();
return m_trace.size();
}

References m_trace, and sizeChangedSignal().

## initialize() [5/6]

void pappso::TraceJs::initialize | ( | const QVariantMap & | map | ) |

Definition at line 95 of file tracejs.cpp.

{
m_trace.clear();
m_trace.reserve(map.size());
for(auto it = map.constBegin(); it != map.constEnd(); ++it)
{
bool key_ok, value_ok;
double key = it.key().toDouble(&key_ok);
double value = it.value().toDouble(&value_ok);
if(key_ok && value_ok)
m_trace.emplace_back(key, value);
else
qWarning() << "Skipping invalid map entry at key:" << it.key();
}
emit sizeChangedSignal();
}

References m_trace, and sizeChangedSignal().

## initialize() [6/6]

size_t pappso::TraceJs::initialize | ( | const TraceJs & | other | ) |

Definition at line 153 of file tracejs.cpp.

{
m_trace.clear();
m_trace.reserve(other.m_trace.size());
std::copy(other.m_trace.begin(), other.m_trace.end(), std::back_inserter(m_trace));
emit sizeChangedSignal();
return m_trace.size();
}

References TraceJs(), m_trace, and sizeChangedSignal().

## operator=()

TraceJs & pappso::TraceJs::operator= | ( | const TraceJs & |  | ) |

delete

References TraceJs(), append(), clear(), getPointAt(), getSize(), getTrace(), initialize(), registerJsConstructor(), toMap(), xValues(), and yValues().

## registerJsConstructor()

void pappso::TraceJs::registerJsConstructor | ( | QJSEngine * | engine | ) |

static

Definition at line 214 of file tracejs.cpp.

{
if(!engine)
{
qWarning() << "Cannot register class: engine is null";
return;
}
// Register the meta object as a constructor
QJSValue jsMetaObject = engine->newQMetaObject(&TraceJs::staticMetaObject);
engine->globalObject().setProperty("Trace", jsMetaObject);
}

Referenced by operator=().

## sizeChangedSignal

void pappso::TraceJs::sizeChangedSignal | ( |  | ) |

signal

Referenced by append(), append(), initialize(), initialize(), initialize(), initialize(), initialize(), and initialize().

## toMap()

QVariantMap pappso::TraceJs::toMap | ( |  | ) | const

Definition at line 197 of file tracejs.cpp.

{
QVariantMap map;
for(const auto &point : m_trace)
{
map.insert(QString::number(point.x), point.y);
}
return map;
}

References m_trace.

Referenced by operator=().

## xValues()

QVariantList pappso::TraceJs::xValues | ( |  | ) | const

Definition at line 169 of file tracejs.cpp.

{
QVariantList list;
list.reserve(m_trace.size());
for(const DataPoint &point : m_trace)
{
list.append(QVariant::fromValue(point.x));
}
return list;
}

References m_trace.

Referenced by operator=().

## yValues()

QVariantList pappso::TraceJs::yValues | ( |  | ) | const

Definition at line 183 of file tracejs.cpp.

{
QVariantList list;
list.reserve(m_trace.size());
for(const DataPoint &point : m_trace)
{
list.append(QVariant::fromValue(point.y));
}
return list;
}

References m_trace.

Referenced by operator=().

## Member Data Documentation

## m_trace

Trace pappso::TraceJs::m_trace

private

Definition at line 69 of file tracejs.h.

Referenced by TraceJs(), TraceJs(), append(), append(), clear(), getPointAt(), getSize(), getTrace(), initialize(), initialize(), initialize(), initialize(), initialize(), initialize(), toMap(), xValues(), and yValues().

## Property Documentation

## size

int pappso::TraceJs::size

read

Definition at line 29 of file tracejs.h.

The documentation for this class was generated from the following files:

- pappsomspp/core/js_qml/tracejs.h
- pappsomspp/core/js_qml/tracejs.cpp