libpappsomspp
Library for mass spectrometry
pappso::DataPoint Struct Reference

#include <datapoint.h>

Public Member Functions

 DataPoint ()
 
 DataPoint (const DataPoint &other)
 
 DataPoint (pappso_double x, pappso_double y)
 
 DataPoint (std::pair< pappso_double, pappso_double > pair)
 
DataPointCstSPtr makeDataPointCstSPtr () const
 
void initialize (pappso_double x, pappso_double y)
 
void initialize (const DataPoint &other)
 
bool initialize (const QString &text)
 
void reset ()
 
void incrementX (pappso_double value)
 
void incrementY (pappso_double value)
 
bool operator== (const DataPoint &other) const
 
DataPointoperator= (const DataPoint &other)
 
bool isValid () const
 
QString toString () const
 

Public Attributes

pappso_double x = -1
 
pappso_double y = 0
 

Detailed Description

Definition at line 20 of file datapoint.h.

Constructor & Destructor Documentation

◆ DataPoint() [1/4]

pappso::DataPoint::DataPoint ( )

Definition at line 25 of file datapoint.cpp.

26 {
27 }

◆ DataPoint() [2/4]

pappso::DataPoint::DataPoint ( const DataPoint other)

Definition at line 30 of file datapoint.cpp.

30  : x(other.x), y(other.y)
31 {
32 }

References pappso::x, and pappso::y.

◆ DataPoint() [3/4]

pappso::DataPoint::DataPoint ( pappso_double  x,
pappso_double  y 
)

Definition at line 35 of file datapoint.cpp.

35  : x(x), y(y)
36 {
37 }

References pappso::x, and pappso::y.

◆ DataPoint() [4/4]

pappso::DataPoint::DataPoint ( std::pair< pappso_double, pappso_double pair)

Definition at line 40 of file datapoint.cpp.

41  : x(pair.first), y(pair.second)
42 {
43 }

References pappso::x, and pappso::y.

Member Function Documentation

◆ incrementX()

void pappso::DataPoint::incrementX ( pappso_double  value)

Definition at line 159 of file datapoint.cpp.

160 {
161  x += value;
162 }

References x.

◆ incrementY()

void pappso::DataPoint::incrementY ( pappso_double  value)

Definition at line 166 of file datapoint.cpp.

167 {
168  y += value;
169 }

References y.

◆ initialize() [1/3]

void pappso::DataPoint::initialize ( const DataPoint other)

Definition at line 70 of file datapoint.cpp.

71 {
72  x = other.x;
73  y = other.x;
74 }

References x, and y.

◆ initialize() [2/3]

bool pappso::DataPoint::initialize ( const QString &  text)

Definition at line 78 of file datapoint.cpp.

79 {
80  QRegularExpressionMatch regExpMatch;
81 
82  regExpMatch = Utils::xyMassDataFormatRegExp.match(text);
83 
84  if(!regExpMatch.hasMatch())
85  return false;
86 
87  bool ok = false;
88 
89  double key = regExpMatch.captured(1).toDouble(&ok);
90 
91  if(!ok)
92  return false;
93 
94  // Note that group 2 is the separator group.
95 
96  double val = regExpMatch.captured(3).toDouble(&ok);
97 
98  if(!ok)
99  return false;
100 
101  x = key;
102  y = val;
103 
104  return true;
105 }

References x, pappso::Utils::xyMassDataFormatRegExp, and y.

◆ initialize() [3/3]

void pappso::DataPoint::initialize ( pappso_double  x,
pappso_double  y 
)

Definition at line 62 of file datapoint.cpp.

63 {
64  this->x = x;
65  this->y = y;
66 }

References x, and y.

◆ isValid()

bool pappso::DataPoint::isValid ( ) const

Definition at line 117 of file datapoint.cpp.

118 {
119  return (x >= 0);
120 }

References x.

Referenced by pappso::MassSpectrumPlusCombiner::combineNoFilteringStep(), and pappso::MassSpectrumMinusCombiner::combineNoFilteringStep().

◆ makeDataPointCstSPtr()

DataPointCstSPtr pappso::DataPoint::makeDataPointCstSPtr ( ) const

Definition at line 55 of file datapoint.cpp.

56 {
57  return std::make_shared<const DataPoint>(*this);
58 }

Referenced by pappso::MassSpectrumWidget::peakChangeEvent().

◆ operator=()

DataPoint & pappso::DataPoint::operator= ( const DataPoint other)

Definition at line 179 of file datapoint.cpp.

180 {
181  x = other.x;
182  y = other.y;
183 
184  return *this;
185 }

References x, and y.

◆ operator==()

bool pappso::DataPoint::operator== ( const DataPoint other) const

Definition at line 172 of file datapoint.cpp.

173 {
174  return ((x == other.x) && (y == other.y));
175 }

References x, and y.

◆ reset()

void pappso::DataPoint::reset ( )

Definition at line 109 of file datapoint.cpp.

110 {
111  x = -1;
112  y = 0;
113 }

References x, and y.

◆ toString()

QString pappso::DataPoint::toString ( ) const

Definition at line 124 of file datapoint.cpp.

125 {
126  return QString("(%1,%2)").arg(x, 0, 'f', 15).arg(y, 0, 'f', 15);
127 }

References x, and y.

Member Data Documentation

◆ x

◆ y


The documentation for this struct was generated from the following files:
pappso::DataPoint::y
pappso_double y
Definition: datapoint.h:23
pappso::DataPoint::x
pappso_double x
Definition: datapoint.h:22
pappso::Utils::xyMassDataFormatRegExp
static QRegularExpression xyMassDataFormatRegExp
Definition: utils.h:74