libpappsomspp
Library for mass spectrometry
pappso::FilterResampleKeepXRange Class Reference

#include <filterresample.h>

Inheritance diagram for pappso::FilterResampleKeepXRange:
pappso::FilterInterface

Public Member Functions

 FilterResampleKeepXRange (double min_x=0, double max_x=0)
 
 FilterResampleKeepXRange (const FilterResampleKeepXRange &other)
 
virtual ~FilterResampleKeepXRange ()
 
FilterResampleKeepXRangeoperator= (const FilterResampleKeepXRange &other)
 
Tracefilter (Trace &trace) const override
 
- Public Member Functions inherited from pappso::FilterInterface
virtual ~FilterInterface ()
 

Private Attributes

double m_minX
 
double m_maxX
 

Detailed Description

Definition at line 86 of file filterresample.h.

Constructor & Destructor Documentation

◆ FilterResampleKeepXRange() [1/2]

pappso::FilterResampleKeepXRange::FilterResampleKeepXRange ( double  min_x = 0,
double  max_x = 0 
)

Definition at line 141 of file filterresample.cpp.

142  : m_minX(min_x), m_maxX(max_x)
143 {
144 }

◆ FilterResampleKeepXRange() [2/2]

pappso::FilterResampleKeepXRange::FilterResampleKeepXRange ( const FilterResampleKeepXRange other)

Definition at line 146 of file filterresample.cpp.

148  : m_minX(other.m_minX), m_maxX(other.m_maxX)
149 {
150 }

◆ ~FilterResampleKeepXRange()

virtual pappso::FilterResampleKeepXRange::~FilterResampleKeepXRange ( )
inlinevirtual

Definition at line 95 of file filterresample.h.

95 {};

Member Function Documentation

◆ filter()

Trace & pappso::FilterResampleKeepXRange::filter ( Trace trace) const
overridevirtual

Implements pappso::FilterInterface.

Definition at line 167 of file filterresample.cpp.

168 {
169  qDebug() << "The range to keep:" << m_minX << "-" << m_maxX;
170 
171  auto begin_it =
172  findFirstEqualOrGreaterX(spectrum.begin(), spectrum.end(), m_minX);
173 
174  qDebug() << "Found begin iterator (for m_minX) having:" << begin_it->x
175  << "x (m/z) value";
176 
177  auto end_it = findFirstGreaterX(begin_it, spectrum.end(), m_maxX);
178 
179  if(end_it == spectrum.end())
180  {
181  qDebug() << "The end iterator (for m_maxX) is the end(). The prev "
182  "iterator has"
183  << std::prev(end_it)->x << " x(m / z) value.";
184  }
185  else
186  qDebug() << "Found end iterator (for m_maxX) having:" << end_it->x
187  << "x (m/z) value";
188 
189  qDebug() << "Only keeping range" << begin_it->x << "-"
190  << std::prev(end_it)->x;
191 
192  spectrum.erase(end_it, spectrum.end());
193  spectrum.erase(spectrum.begin(), begin_it);
194 
195  return spectrum;
196 }
std::vector< DataPoint >::iterator findFirstEqualOrGreaterX(std::vector< DataPoint >::iterator begin, std::vector< DataPoint >::iterator end, const double &value)
find the first element in which X is equal or greater than the value searched important : it implies ...
Definition: trace.cpp:32
std::vector< DataPoint >::iterator findFirstGreaterX(std::vector< DataPoint >::iterator begin, std::vector< DataPoint >::iterator end, const double &value)
find the first element in which X is greater than the value searched important : it implies that Trac...
Definition: trace.cpp:60

References pappso::findFirstEqualOrGreaterX(), pappso::findFirstGreaterX(), m_maxX, and m_minX.

Referenced by pappso::MassSpectrumFilterResampleKeepMzRange::filter(), pappso::FilterResampleKeepPointInPolygon::filter(), and pappso::MsRunXicExtractor::getXicCstSPtr().

◆ operator=()

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

Definition at line 154 of file filterresample.cpp.

155 {
156  if(&other == this)
157  return *this;
158 
159  m_minX = other.m_minX;
160  m_maxX = other.m_maxX;
161 
162  return *this;
163 }

References m_maxX, and m_minX.

Member Data Documentation

◆ m_maxX

double pappso::FilterResampleKeepXRange::m_maxX
private

Definition at line 90 of file filterresample.h.

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

◆ m_minX

double pappso::FilterResampleKeepXRange::m_minX
private

Definition at line 89 of file filterresample.h.

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


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