Mass++ Common Libraries v2.7.5
 All Classes Namespaces Files Functions Variables Enumerations Macros
ManipulatedSample.cpp
Go to the documentation of this file.
1 
12 #include "stdafx.h"
13 #include "ManipulatedSample.h"
14 #include "ManipulatedSpectrum.h"
15 #include "Normalization.h"
17 
18 
19 using namespace kome::operation;
20 
21 
22 #include <crtdbg.h>
23 #ifdef _DEBUG
24  #define new new( _NORMAL_BLOCK, __FILE__, __LINE__ )
25  #define malloc( s ) _malloc_dbg( s, _NORMAL_BLOCK, __FILE__, __LINE__ )
26 #endif // _DEBUG
27 
28 
29 
30 // constructor
32  : kome::objects::Sample( NULL ), m_org( org ){
33 
34  m_opts.clear();
35 
36  setType( org.getType() );
38  setSampleId( org.getSampleId() );
39  setName( org.getName() );
40  setOpened( org.isOpened() );
41  setEdited( org.isEdited() );
42 
43  if( m_root != NULL ){
44  delete m_root;
45  }
46  m_root = NULL;
47 
49  if( m_root != NULL ){
52  }
54  getGroups( NULL );
55 }
56 
57 // destructor
59  if( m_root != NULL ){
60  delete m_root;
61  }
62  m_root = NULL;
63 
65 }
66 
67 // add spectrum
69  if( orgGroup != NULL && dstGroup != NULL ){
70  // creating spectra
71  for( unsigned int i=0; i < orgGroup->getNumberOfSpectra(); i++ ){
73  dstGroup->addSpectrum( spec );
74  spec->setSample( this );
75  }
76 
77  // creating chromatograms
78  for( unsigned int i = 0; i < orgGroup->getNumberOfChromatograms(); i++ ) {
79  kome::objects::Chromatogram* orgChrom = orgGroup->getChromatogram( i );
80  TransformedChromatogram* chrom = new TransformedChromatogram( *orgChrom, false );
81  dstGroup->addChromatogram( chrom );
82  }
83 
84  // child groups
85  for( unsigned int i = 0; i < orgGroup->getNumberOfChildren(); i++ ) {
86  kome::objects::DataGroupNode* orgChild = orgGroup->getChild( i );
87  kome::objects::DataGroupNode* dstChild = dstGroup->createChildGroup( orgChild->getName() );
88 
89  addSpectrum( orgChild, dstChild );
90  }
91  }
92 }
93 
94 // add normaliz operation
96  bool bflg = false;
97  for( unsigned int i=0; i < m_opts.size(); i++ ){
98  if( opt == m_opts[i] ){
99  bflg = true;
100  break;
101  }
102  }
103  if( bflg ){
104  m_opts.push_back( opt );
105  }
106 }
107 
108 // remove operation
110 
111  for( unsigned int i=0; i < m_opts.size(); i++ ){
112  if( opt == m_opts[i] ){
113  delete m_opts[i];
114  m_opts.erase( m_opts.begin() + i );
115  return;
116  }
117  }
118 }
119 
120 // clear Operation
122  for( unsigned int i=0; i < m_opts.size(); i++ ){
123  delete m_opts[i];
124  }
125  m_opts.clear();
126 }
127 
128 // set normaliz operation info
130  // create filter subtract object
131  Normalization* normaliz = new Normalization();
132 
133  normaliz->setNormalizInfo( call, settings, stdGroup );
134  m_opts.push_back( (kome::objects::XYDataOperation*)normaliz );
135 }
136 
137 // on open sample
139  return true;
140 }
141 
142 // on close sample
144  if( m_root != NULL ){
145  delete m_root;
146  }
147  m_root = NULL;
148 
149  clearOperation();
150 
151  return true;
152 }
153 
154 // get org sample
156  return &m_org;
157 }
158 
159 // get number of operation
161  return m_opts.size();
162 }
163 
164 // get operation
166 
167  // check the index
168  if( index >= (int)m_opts.size() ) {
169  return NULL;
170  }
171  return m_opts[ index ];
172 
173 }
unsigned int getNumberOfOperation()
get number of operation
Normalization class.
group of spectrum management class
Definition: DataGroupNode.h:33
bool isEdited()
judges whther this sample is edited or not
Definition: Sample.cpp:214
virtual void clearSpectra()
clears spectra
Definition: DataSet.cpp:162
void setSample(ManipulatedSample *sample)
set sample object
void setName(const char *name)
sets sample name
Definition: Sample.cpp:92
DataGroupNode * getChild(const unsigned int index)
gets child group
sample information management class
Definition: Sample.h:34
setting parameter values management class
const char * getName()
gets group name
virtual void addChromatogram(Chromatogram *chrom)
adds chromatogram
Definition: DataSet.cpp:217
void removeOperation(kome::objects::XYDataOperation *opt)
remove operation
unsigned int getNumberOfSpectra()
gets the number of spectra
Definition: DataSet.cpp:128
const char * getName()
gets sample name
Definition: Sample.cpp:102
progress display abstract class
Definition: Progress.h:31
Spectrum * getSpectrum(const unsigned int index)
gets the number of spectra
Definition: DataSet.cpp:133
const char * getType()
gets sample type
Definition: Sample.cpp:117
Manipulated Spectrum class.
Chromatogram * getChromatogram(const unsigned int index)
gets chroamtogram
Definition: DataSet.cpp:146
std::vector< kome::objects::XYDataOperation * > m_opts
#define NULL
Definition: CoreMacros.h:18
void addOperation(kome::objects::XYDataOperation *opt)
add operation
DataGroupNode * createChildGroup(const char *name)
creates new child group object
unsigned int getNumberOfChromatograms()
gets the number of chromatograms
Definition: DataSet.cpp:141
void setSampleId(int id)
set sample id
Definition: Sample.cpp:437
kome::objects::Sample * getOrgSample()
gets original sample
void setEdited(const bool edited)
sets edited flag
Definition: Sample.cpp:209
int getSampleIndex()
gets sample index
Definition: Sample.cpp:87
interfaces of TransformedChromatogram class
normalization class
Definition: Normalization.h:28
DataGroupNode * getRootDataGroupNode()
gets root spectrum group
Definition: Sample.cpp:219
void setType(const char *type)
sets sample type
Definition: Sample.cpp:107
void setSampleIndex(const int index)
sets sample index
Definition: Sample.cpp:82
virtual bool onOpenSample(kome::objects::DataGroupNode *rootGroup, kome::core::Progress *progress=NULL)
This method is called by openSample method. (abstract method)
void addSpectrum(kome::objects::DataGroupNode *orgGroup, kome::objects::DataGroupNode *dstGroup)
add spectrum
void setOperationInfo(kome::plugin::PluginCall *call, kome::objects::SettingParameterValues *settings, kome::objects::DataGroupNode *stdGroup)
set operation info
void getGroups(DataGroupNode *parentGroup=NULL)
gets spectrum groups
Definition: Sample.cpp:242
void setNormalizInfo(kome::plugin::PluginCall *func, kome::objects::SettingParameterValues *settings, kome::objects::DataGroupNode *stdGroup)
sets filter information
virtual void clearChromatograms()
clears chromatograms
Definition: DataSet.cpp:212
int getSampleId()
get sample id
Definition: Sample.cpp:442
chromatogram information management class
Definition: Chromatogram.h:33
Manipulated Sample class.
xy data operation class
bool isOpened()
judges whther this sample is opened or not
Definition: Sample.cpp:204
ManipulatedSample(kome::objects::Sample &org)
constructor
void setOpened(const bool opened)
sets opened flag
Definition: Sample.cpp:199
kome::objects::XYDataOperation * getOperation(int index)
get operation
unsigned int getNumberOfChildren()
gets the number of children
virtual void addSpectrum(Spectrum *spec)
adds spectrum to group
Definition: DataSet.cpp:167
DataGroupNode * m_root
Definition: Sample.h:77
virtual bool onCloseSample()
This method is called by closeSample method. (abstract method)