v2.0.0
Loading...
Searching...
No Matches
spectrumview.cpp
Go to the documentation of this file.
1//=============================================================================================================
35
36//=============================================================================================================
37// INCLUDES
38//=============================================================================================================
39
40#include "spectrumview.h"
41
44
45#include <fiff/fiff_info.h>
46
47//=============================================================================================================
48// QT INCLUDES
49//=============================================================================================================
50
51#include <QGridLayout>
52#include <QHeaderView>
53#include <QTableView>
54#include <QMouseEvent>
55#include <QSettings>
56
57//=============================================================================================================
58// USED NAMESPACES
59//=============================================================================================================
60
61using namespace DISPLIB;
62using namespace FIFFLIB;
63using namespace Eigen;
64
65//=============================================================================================================
66// DEFINE MEMBER METHODS
67//=============================================================================================================
68
69SpectrumView::SpectrumView(const QString& sSettingsPath,
70 QWidget *parent,
71 Qt::WindowFlags f)
72: AbstractView(parent, f)
73{
74 m_sSettingsPath = sSettingsPath;
75 m_pTableView = new QTableView;
76
77 m_pTableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
78 m_pTableView->setMouseTracking(true);
79 m_pTableView->viewport()->installEventFilter(this);
80
81 //set vertical layout
82 QVBoxLayout *neLayout = new QVBoxLayout(this);
83
84 neLayout->addWidget(m_pTableView);
85
86 //set layouts
87 this->setLayout(neLayout);
89}
90
91//=============================================================================================================
92
97
98//=============================================================================================================
99
101 int iScaleType)
102{
104
105 m_pFSModel->setInfo(info);
106 m_pFSModel->setScaleType(iScaleType); /*Added by Limin; 10/19/2014 for passing the scale type to the model*/
107
109 m_pFSDelegate->setScaleType(iScaleType);
110
111 connect(m_pTableView.data(), &QTableView::doubleClicked,
113
114 // add a connection for sending mouse location to the delegate;
115 connect(this, &SpectrumView::sendMouseLoc,
117
118 m_pTableView->setModel(m_pFSModel);
119 m_pTableView->setItemDelegate(m_pFSDelegate);
120
121 //set some size settings for m_pTableView
122 m_pTableView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
123
124 m_pTableView->setShowGrid(false);
125
126 m_pTableView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); //Stretch 2 column to maximal width
127 m_pTableView->horizontalHeader()->hide();
128 m_pTableView->verticalHeader()->setDefaultSectionSize(140);//m_fZoomFactor*m_fDefaultSectionSize);//Row Height
129
130 m_pTableView->setAutoScroll(false);
131 m_pTableView->setColumnHidden(0,true); //because content is plotted jointly with column=1
132
133 m_pTableView->resizeColumnsToContents();
134
135 m_pTableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
136
137 //set context menu
138 m_pTableView->setContextMenuPolicy(Qt::CustomContextMenu);
139 //connect(m_pTableView,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(channelContextMenu(QPoint)));
140}
141
142//=============================================================================================================
143
144void SpectrumView::addData(const MatrixXd &data)
145{
146 m_pFSModel->addData(data);
147}
148
149//=============================================================================================================
150
152 int iUpper)
153{
154 m_pFSModel->setBoundaries(iLower, iUpper);
155}
156
157//=============================================================================================================
158
159bool SpectrumView::eventFilter(QObject * watched,
160 QEvent * event)
161{
162 if(event->type() == QEvent::MouseMove){
163 QMouseEvent *mouseEvent = static_cast <QMouseEvent*>( event );
164 //qDebug()<<"MouseMove event!@"<<mouseEvent->x()<<":"<<mouseEvent->y();
165
166 int currentRow = m_pTableView->rowAt(static_cast<int>(mouseEvent->position().y()));
167 m_pTableView->selectRow(currentRow);
168
169 QModelIndex item = m_pTableView->currentIndex();
170
171 emit sendMouseLoc(item.row(), static_cast<int>(mouseEvent->position().x()), static_cast<int>(mouseEvent->position().y()),m_pTableView->visualRect(item) );
172
173 return true;
174 } else {
175 return QWidget::eventFilter(watched, event);
176 }
177}
178
179//=============================================================================================================
180
182{
183 if(m_sSettingsPath.isEmpty()) {
184 return;
185 }
186
187 // Save Settings
188 QSettings settings("MNECPP");
189}
190
191//=============================================================================================================
192
194{
195 if(m_sSettingsPath.isEmpty()) {
196 return;
197 }
198
199 // Load Settings
200 QSettings settings("MNECPP");
201}
202
203//=============================================================================================================
204
206{
207 switch(mode) {
209 break;
210 default: // default is research mode
211 break;
212 }
213}
214
215//=============================================================================================================
216
218{
219 switch(mode) {
221 break;
222 default: // default is realtime mode
223 break;
224 }
225}
226
227//=============================================================================================================
228
230{
231
232}
Declaration of the SpectrumView Class.
Declaration of the FrequencySpectrumModel Class.
Declaration of the FrequencySpectrumDelegate Class.
FiffInfo class declaration.
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
2-D display widgets and visualisation helpers (charts, topography, colour maps).
AbstractView(QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
The FrequencySpectrumDelegate class represents a frequency delegate which creates the plot paths.
void rcvMouseLoc(int row, int x, int y, QRect visRect)
The FrequencySpectrumModel class implements the data access model for a real-time multi sample array ...
void toggleFreeze(const QModelIndex &index)
QPointer< QTableView > m_pTableView
QPointer< DISPLIB::FrequencySpectrumModel > m_pFSModel
void updateGuiMode(GuiMode mode)
void addData(const Eigen::MatrixXd &data)
SpectrumView(const QString &sSettingsPath="", QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
virtual bool eventFilter(QObject *watched, QEvent *event)
QPointer< DISPLIB::FrequencySpectrumDelegate > m_pFSDelegate
void setBoundaries(int iLower, int iUpper)
void init(QSharedPointer< FIFFLIB::FiffInfo > &info, int iScaleType)
void updateProcessingMode(ProcessingMode mode)
void sendMouseLoc(int row, int x, int y, QRect visRect)
QSharedPointer< FiffInfo > SPtr
Definition fiff_info.h:87