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

`#include <maptrace.h>`

Inheritance diagram for pappso::MapTrace:

## Public Member Functions

| MapTrace ()
| MapTrace (const std::vector< std::pair< pappso_double, pappso_double > > &dataPoints)
| MapTrace (const std::vector< DataPoint > &dataPoints)
| MapTrace (const MapTrace &other)
| MapTrace (const Trace &trace)
virtual | ~MapTrace ()
size_t | initialize (const std::vector< pappso_double > &xVector, const std::vector< pappso_double > &yVector)
size_t | initialize (const std::map< pappso_double, pappso_double > &map)
virtual MapTrace & | operator= (const MapTrace &other)
MapTraceSPtr | makeMapTraceSPtr () const
MapTraceCstSPtr | makeMapTraceCstSPtr () const
std::vector< pappso_double > | xValues ()
std::vector< pappso_double > | yValues ()
void | insertOrUpdate (const DataPoint &data_point)
void | insertOrUpdate (const Trace &trace)
Trace | toTrace () const
QString | toString () const

## Detailed Description

Definition at line 35 of file maptrace.h.

## Constructor & Destructor Documentation

## MapTrace() [1/5]

pappso::MapTrace::MapTrace | ( |  | ) |

Definition at line 29 of file maptrace.cpp.

{
}

Referenced by MapTrace(), and operator=().

## MapTrace() [2/5]

pappso::MapTrace::MapTrace | ( | const std::vector< std::pair< pappso_double, pappso_double > > & | dataPoints | ) |

Definition at line 34 of file maptrace.cpp.

{
for(auto &dataPoint : dataPoints)
{
insert(dataPoint);
}
}

## MapTrace() [3/5]

pappso::MapTrace::MapTrace | ( | const std::vector< DataPoint > & | dataPoints | ) |

Definition at line 43 of file maptrace.cpp.

{
for(auto &dataPoint : dataPoints)
{
insert(std::pair<pappso_double, pappso_double>(dataPoint.x, dataPoint.y));
}
}

## MapTrace() [4/5]

pappso::MapTrace::MapTrace | ( | const MapTrace & | other | ) |

Definition at line 52 of file maptrace.cpp.

: std::map<pappso_double, pappso_double>(other)
{
}

References MapTrace().

## MapTrace() [5/5]

pappso::MapTrace::MapTrace | ( | const Trace & | trace | ) |

Definition at line 57 of file maptrace.cpp.

{
// qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()";
for(auto &dataPoint : trace)
{
// std::cout << __FILE__ << " @ " << __LINE__ << " " << __FUNCTION__ << "
// () "
//<< std::setprecision(15)
//<< "Current data point: " << dataPoint.toString().toStdString() <<
// std::endl;
insert(std::pair<pappso_double, pappso_double>(dataPoint.x, dataPoint.y));
}
// qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << " ()"
//<< "After construction, map size: " << size();
}

## ~MapTrace()

pappso::MapTrace::~MapTrace | ( |  | ) |

virtual

Definition at line 77 of file maptrace.cpp.

{
// Calls the destructor for each DataPoint object in the vector.
clear();
}

## Member Function Documentation

## initialize() [1/2]

size_t pappso::MapTrace::initialize | ( | const std::map< pappso_double, pappso_double > & | map | ) |

Definition at line 110 of file maptrace.cpp.

{
// Clear *this, because initialize supposes that *this will be identical to
// map.
clear();
for(auto &&pair : map)
{
insert(pair);
}
return size();
}

## initialize() [2/2]

size_t pappso::MapTrace::initialize | ( | const std::vector< pappso_double > & | xVector,
|  | const std::vector< pappso_double > & | yVector )

Definition at line 85 of file maptrace.cpp.

{
// Clear *this, because initialize supposes that *this will contain only the
// data in the vectors.
clear();
// Sanity check
if(xVector.size() != yVector.size())
throw ExceptionNotPossible(
QObject::tr("Fatal error at msrundatasettreenode.cpp "
"-- ERROR xVector and yVector must have the same size."
"Program aborted."));
for(std::size_t iter = 0; iter < xVector.size(); ++iter)
{
insert(std::pair<pappso_double, pappso_double>(xVector.at(iter), yVector.at(iter)));
}
return size();
}

## insertOrUpdate() [1/2]

void pappso::MapTrace::insertOrUpdate | ( | const DataPoint & | data_point | ) |

Definition at line 187 of file maptrace.cpp.

{
// Try to insert the data point into the map. Check if that was done or
// not.
std::pair<std::map<double, double>::iterator, bool> res =
insert(std::pair<double, double>(data_point.x, data_point.y));
if(!res.second)
{
// One other same (x,y) value pair was seen already. Only increment the y
// value.
res.first->second += data_point.y;
}
}
pappso::Enums::PrecisionUnit::res
@ res
Definition types.h:100

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

Referenced by insertOrUpdate().

## insertOrUpdate() [2/2]

void pappso::MapTrace::insertOrUpdate | ( | const Trace & | trace | ) |

Definition at line 206 of file maptrace.cpp.

{
for(const DataPoint &data_point : trace)
insertOrUpdate(data_point);
}
pappso::MapTrace::insertOrUpdate
void insertOrUpdate(const DataPoint &data_point)
Definition maptrace.cpp:187

References insertOrUpdate().

## makeMapTraceCstSPtr()

MapTraceCstSPtr pappso::MapTrace::makeMapTraceCstSPtr | ( |  | ) | const

Definition at line 156 of file maptrace.cpp.

{
return std::make_shared<const MapTrace>(*this);
}

## makeMapTraceSPtr()

MapTraceSPtr pappso::MapTrace::makeMapTraceSPtr | ( |  | ) | const

Definition at line 149 of file maptrace.cpp.

{
return std::make_shared<MapTrace>(*this);
}

## operator=()

MapTrace & pappso::MapTrace::operator= | ( | const MapTrace & | other | ) |

virtual

Definition at line 128 of file maptrace.cpp.

{
if(&other == this)
return *this;
// Clear *this, because initialize supposes that *this will be identical to
// other.
clear();
for(auto &pair : other)
{
insert(pair);
}
return *this;
}

References MapTrace().

## toString()

QString pappso::MapTrace::toString | ( |  | ) | const

Definition at line 226 of file maptrace.cpp.

{
// Even if the spectrum is empty, we should return an empty string.
QString text;
for(auto &&pair : *this)
{
// For debugging
#if 0
QString new_data_point_text = QString("%1 %2\n")
.arg(pair.first, 0, 'f', 10)
.arg(pair.second, 0, 'f', 10);
qDebug() << "new data point text:" << new_data_point_text;
text.append(new_data_point_text);
#endif
text.append(QString("%1 %2\n").arg(pair.first, 0, 'f', 10).arg(pair.second, 0, 'f', 10));
}
return text;
}

## toTrace()

Trace pappso::MapTrace::toTrace | ( |  | ) | const

Definition at line 214 of file maptrace.cpp.

{
Trace trace;
for(auto &&pair : *this)
trace.push_back(DataPoint(pair.first, pair.second));
return trace;
}

Referenced by pappso::TraceMinusCombiner::combine(), pappso::TracePlusCombiner::combine(), pappso::TimsData::getTicChromatogram(), and pappso::FilterLowIntensitySignalRemoval::reconstructTrace().

## xValues()

std::vector< pappso_double > pappso::MapTrace::xValues | ( |  | ) |

Definition at line 163 of file maptrace.cpp.

{
std::vector<pappso_double> vector;
for(auto &&pair : *this)
vector.push_back(pair.first);
return vector;
}

## yValues()

std::vector< pappso_double > pappso::MapTrace::yValues | ( |  | ) |

Definition at line 175 of file maptrace.cpp.

{
std::vector<pappso_double> vector;
for(auto &&pair : *this)
vector.push_back(pair.second);
return vector;
}

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

- pappsomspp/core/trace/maptrace.h
- pappsomspp/core/trace/maptrace.cpp