MNE-CPP  beta 1.0
ecgsimchannel.cpp
Go to the documentation of this file.
1 //=============================================================================================================
37 //*************************************************************************************************************
38 //=============================================================================================================
39 // INCLUDES
40 //=============================================================================================================
41 
42 #include "ecgsimchannel.h"
43 
44 
45 //*************************************************************************************************************
46 //=============================================================================================================
47 // QT INCLUDES
48 //=============================================================================================================
49 
50 #include <QtCore/QTextStream>
51 #include <QtCore/QFile>
52 
53 
54 //*************************************************************************************************************
55 //=============================================================================================================
56 // USED NAMESPACES
57 //=============================================================================================================
58 
59 using namespace ECGSimulatorPlugin;
60 
61 
62 //*************************************************************************************************************
63 //=============================================================================================================
64 // DEFINE MEMBER METHODS
65 //=============================================================================================================
66 
67 ECGSimChannel::ECGSimChannel(QString ResourceDataPath, QString ChannelFile, bool enabled, bool visible)
68 : m_qStringResourceDataPath(ResourceDataPath)
69 , m_qStringChannelFile(ChannelFile)
70 , m_bIsEnabled(enabled)
71 , m_bIsVisible(visible)
72 {
73 
74 }
75 
76 
77 //*************************************************************************************************************
78 
80 {
81 }
82 
83 
84 //*************************************************************************************************************
85 
87 {
88  QFile file;
89  file.setFileName(m_qStringResourceDataPath+m_qStringChannelFile);
90  if(file.open(QIODevice::ReadOnly | QIODevice::Text))
91  {
92  QTextStream in(&file);
93  double value;
94 
95  while(!in.atEnd())
96  {
97  in >> value;
98 
99  //init min and max with first value
100  if(m_vecBuffer.size() == 0)
101  {
102  m_dMin = value;
103  m_dMax = value;
104  }
105 
106  if(value < m_dMin)
107  m_dMin = value;
108 
109  if(value > m_dMax)
110  m_dMax = value;
111 
112  m_vecBuffer.push_back(value);
113 
114  }
115  file.close();
116  }
117 }
118 
119 
120 //*************************************************************************************************************
121 
123 {
124  m_vecBuffer.clear();
125 }
ECGSimChannel(QString ResourceDataPath, QString ChannelFile, bool enabled=true, bool visible=true)
Contains the declaration of the ECGChannel class.