Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
TransformedSpectrum.cpp
Go to the documentation of this file.
1 
12 #include "stdafx.h"
13 #include "TransformedSpectrum.h"
14 
15 
16 using namespace kome::operation;
17 
18 
19 #include <crtdbg.h>
20 #ifdef _DEBUG
21  #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
22  #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
23 #endif // _DEBUG
24 
25 
26 
27 // constructor
29  : kome::objects::Spectrum( org.getSample(), org.getName() ), m_org( org ) {
30  m_scX = 1.0;
31  m_trX = 0.0;
32  m_scY = 1.0;
33  m_trY = 0.0;
34  m_op = op;
35 
36  setName( org.getName() );
37  setRt( org.getRt() );
38  setStartRt( org.getStartRt() );
39  setEndRt( org.getEndRt() );
40  setSpecType( org.getSpecType() );
41  setTitle( org.getTitle() );
42  setIcon( org.getIcon() );
43  setMinX( org.getMinX() );
44  setMaxX( org.getMaxX() );
47  setMsStage( org.getMsStage() );
48  setPrecursor( org.getPrecursor() );
52  setGroup( org.getGroup() );
54  setPolarity( org.getPolarity() );
58 }
59 
60 // destructor
62 }
63 
64 // set x scale
65 void TransformedSpectrum::setXScale( const double sc ) {
66  m_scX = std::max( sc, 1.0e-10 );
67 }
68 
69 // get x scale
71  return m_scX;
72 }
73 
74 // set x translation
75 void TransformedSpectrum::setXTranslation( const double tr ) {
76  m_trX = tr;
77 }
78 
79 // get x translation
81  return m_trX;
82 }
83 
84 // set y scale
85 void TransformedSpectrum::setYScale( const double sc ) {
86  m_scY = std::max( sc, 1.0e-10 );
87 }
88 
89 // get y scale
91  return m_scY;
92 }
93 
94 // set y translation
95 void TransformedSpectrum::setYTranslation( const double tr ) {
96  m_trY = tr;
97 }
98 
99 // get y translation
101  return m_trY;
102 }
103 
104 // on get xy data
106  kome::core::XYData* const xyData,
107  const double minX,
108  const double maxX
109 ) {
110  // get points
112  m_org.getXYData( &dps, m_op );
113 
114  // transform
115  for( unsigned int i = 0; i < dps.getLength(); i++ ) {
116  const double x = m_scX * dps.getX( i ) + m_trX;
117  const double y = m_scY * dps.getY( i ) + m_trY;
118 
119  if( ( minX < 0.0 || x >= minX ) && ( maxX < 0.0 || x <= maxX ) ) {
120  xyData->addPoint( x, y );
121  }
122  }
123 }
124 
125 // on get x range
126 void TransformedSpectrum::onGetXRange( double* minX, double* maxX ) {
127  // get original x range
128  double orgMinX = m_org.getMinX();
129  double orgMaxX = m_org.getMaxX();
130 
131  // get range
132  if( minX != NULL ) {
133  *minX = m_scX * orgMinX + m_trX;
134  }
135  if( maxX != NULL ) {
136  *maxX = m_scX * orgMaxX + m_trX;
137  }
138 }
139 
140 // on get total intensity
141 double TransformedSpectrum::onGetTotalIntensity( const double minX, const double maxX ) {
142  // x range
143  double orgMinX = minX;
144  if( orgMinX >= 0.0 ) {
145  orgMinX = std::max( ( minX - m_trX ) / m_scX, 0.0 );
146  }
147 
148  double orgMaxX = maxX;
149  if( orgMaxX >= 0.0 ) {
150  orgMaxX = std::max( ( maxX - m_trX ) / m_scX, 0.0 );
151  }
152 
153  // total intensity
154  double intensity = m_org.getTotalIntensity( orgMinX, orgMaxX );
155  intensity = m_scY * intensity + m_trY;
156 
157  return intensity;
158 }
159 
160 // on get max intenisty
161 double TransformedSpectrum::onGetMaxIntensity( const double minX, const double maxX ) {
162  // x range
163  double orgMinX = minX;
164  if( orgMinX >= 0.0 ) {
165  orgMinX = std::max( ( minX - m_trX ) / m_scX, 0.0 );
166  }
167 
168  double orgMaxX = maxX;
169  if( orgMaxX >= 0.0 ) {
170  orgMaxX = std::max( ( maxX - m_trX ) / m_scX, 0.0 );
171  }
172 
173  // max intensity
174  double intensity = m_org.getMaxIntensity( orgMinX, orgMaxX );
175  intensity = m_scY * intensity + m_trY;
176 
177  return intensity;
178 }
179 
180 // >>>>>> @Date:2013/09/05 <Add> A.Ozaki
181 //
182 // set the flag of request load data (virtual)
184 {
185  return;
186 }
187 
188 // set the flag of request load data (virtual)
190 {
191  return;
192 }
193 
194 // check the flag of request load data (virtual)
196 {
198 }
199 
200 // set the flag of first access (virtual)
202 {
203  return;
204 }
205 
206 // reset the flag of first access (virtual)
208 {
209  return;
210 }
211 
212 // check the flag of first access (virtual)
214 {
216 }
217 
218 // load data (virtual)
220 {
222 }
223 
224 //
225 // <<<<<< @Date:2013/09/05 <Add> A.Ozaki
226 
double getStartRt()
gets the start of retention time
Definition: Spectrum.cpp:191
abstraction class of two dimention coordinate data
Definition: XYData.h:34
void setTotalIntensity(const double intensity)
sets total intensity of spectrum
Definition: Spectrum.cpp:505
virtual bool onIsFirstAccess(void)
This method is called by isFirstAccess method. (abstract method)
Definition: Spectrum.cpp:1240
data points data of profile management class
Definition: DataPoints.h:25
virtual void onResetFirstAccess(void)
This method is called by resetFirstAccess method. (abstract method)
double getPrecursor(const int stage)
gets precursor
Definition: Spectrum.cpp:683
double getRt()
gets retention time
Definition: Spectrum.cpp:184
double getX(const unsigned int index)
gets x coordinate
Definition: XYData.cpp:224
interfaces of TransformedSpectrum class
void setMinX(const double minX)
sets min x
Definition: Spectrum.cpp:449
const char * getName()
gets spectrum name
Definition: Spectrum.cpp:123
void setRt(const double rt)
sets retention time
Definition: Spectrum.cpp:129
void setPrecursor(const int stage, const double precursor)
sets precursor
Definition: Spectrum.cpp:640
void setPolarity(Polarity polarity)
sets polarity
Definition: Spectrum.cpp:920
void setPrecursorIntensity(const int stage, const double intensity)
sets precursor intensity
Definition: Spectrum.cpp:702
virtual void onResetRequestLoadData(void)
This method is called by resetRequestLoadData method. (abstract method)
virtual void onGetXRange(double *minX, double *maxX)
This method is called by getMinX or getMaxX method. (override method)
void setMaxX(const double maxX)
sets max x
Definition: Spectrum.cpp:477
virtual bool onIsFirstAccess(void)
This method is called by isFirstAccess method. (abstract method)
const char * getIcon()
gets icon name
Definition: Spectrum.cpp:273
void setXTranslation(const double tr)
sets x translation
void setIcon(const char *icon)
sets icon name
Definition: Spectrum.cpp:268
virtual void onSetRequestLoadData(void)
This method is called by setRequestLoadData method. (abstract method)
void setEndRt(const double rt)
sets end retention time
Definition: Spectrum.cpp:172
void setName(const char *name)
sets spectrum name
Definition: Spectrum.cpp:113
void setParentSpectrum(Spectrum *const parent)
sets parent spectrum
Definition: Spectrum.cpp:821
TransformedSpectrum(kome::objects::Spectrum &org, const bool op=false)
constructor
void setYScale(const double sc)
sets y scale
double getXTranslation()
gets x translation
void setCentroidMode(const bool centroidMode)
sets centroid mode or not
Definition: Spectrum.cpp:935
void setYTranslation(const double tr)
sets y translation
double getY(const unsigned int index)
gets y coordinate
Definition: XYData.cpp:243
Spectrum * getOrgSpectrum()
gets original spectrum
Definition: Spectrum.cpp:1003
double getResolution()
gets resolution
Definition: Spectrum.cpp:952
double getMinX()
gets min x
Definition: Spectrum.cpp:461
int getMsStage()
gets ms stage
Definition: Spectrum.cpp:634
double getMaxX()
gets max x
Definition: Spectrum.cpp:489
void setHasChromatogram(const bool chromatogram)
sets wheher this spectrum has chromatogram
Definition: Spectrum.cpp:883
int getScanNumber()
gets scan number
Definition: Spectrum.cpp:915
double getYTranslation()
gets y translation
#define NULL
Definition: CoreMacros.h:18
double getTotalIntensity(const double minX=-1.0, const double maxX=-1.0)
gets total intensity in specified range
Definition: Spectrum.cpp:516
virtual bool onIsRequestLoadData(void)
This method is called by isRequestLoadData method. (abstract method)
Definition: Spectrum.cpp:1222
void setXScale(const double sc)
sets x scale
kome::core::XYData * getXYData()
gets xy data from data manager
Definition: Spectrum.cpp:279
virtual void onSetFirstAccess(void)
This method is called by setFirstAccess method. (abstract method)
virtual bool onLoadData(void)
This method is called by loadData method. (abstract method)
Definition: Spectrum.cpp:1246
void setMsStage(const int stage)
sets ms stage
Definition: Spectrum.cpp:587
virtual bool onLoadData(void)
This method is called by loadData method. (abstract method)
DataGroupNode * getGroup()
gets spectrum group
Definition: Spectrum.cpp:898
virtual double onGetMaxIntensity(const double minX, const double maxX)
This method is called by getMaxIntensity method. (override method)
void setStartRt(const double rt)
sets start retention time
Definition: Spectrum.cpp:160
void setScanNumber(const int scan)
sets scan number
Definition: Spectrum.cpp:903
void setBasePeakMass(const double mass)
sets base peak mass
Definition: Spectrum.cpp:569
const char * getTitle()
gets spectrum title
Definition: Spectrum.cpp:222
void setOrgSpectrum(Spectrum *spec)
sets original spectrum
Definition: Spectrum.cpp:998
Spectrum * getParentSpectrum()
gets parent spectrum
Definition: Spectrum.cpp:850
spectrum information management class
Definition: Spectrum.h:30
virtual double onGetTotalIntensity(const double minX, const double maxX)
This method is called by getTotalIntensity method. (override method)
double getEndRt()
gets the end of retention time
Definition: Spectrum.cpp:197
void addPoint(const double x, const double y)
adds point
Definition: XYData.cpp:149
void setSpecType(const char *type)
sets spectrum type
Definition: Spectrum.cpp:203
const char * getSpecType()
gets spectrum type
Definition: Spectrum.cpp:209
double getPrecursorIntensity(const int stage)
gets the precursor intensity
Definition: Spectrum.cpp:749
virtual void onGetXYData(kome::core::XYData *const xyData, const double minX, const double maxX)
This method is called by getXYData method. (override method)
void setGroup(DataGroupNode *group)
sets spectrum group
Definition: Spectrum.cpp:893
void setTitle(const char *title)
sets spectrum title
Definition: Spectrum.cpp:215
bool isCentroidMode()
judget wheter this spectrum is centroid mode
Definition: Spectrum.cpp:941
virtual bool onIsRequestLoadData(void)
This method is called by isRequestLoadData method. (abstract method)
void setResolution(const double resolution)
sets resolution
Definition: Spectrum.cpp:946
double getMaxIntensity(const double minX=-1.0, const double maxX=-1.0)
gets max intensity in specified range
Definition: Spectrum.cpp:548
Polarity getPolarity()
gets polarity
Definition: Spectrum.cpp:930
double getBasePeakMass()
gets base peak mass
Definition: Spectrum.cpp:581
unsigned int getLength()
gets the number of points @return the number of points
Definition: XYData.cpp:216
bool hasChromatogram()
judges whether this spectrum has chromatogram
Definition: Spectrum.cpp:888