v2.0.0
Loading...
Searching...
No Matches
spectrumview.cpp
Go to the documentation of this file.
1//=============================================================================================================
14
15//=============================================================================================================
16// INCLUDES
17//=============================================================================================================
18
19#include "spectrumview.h"
20
23
24#include <fiff/fiff_info.h>
25
26//=============================================================================================================
27// QT INCLUDES
28//=============================================================================================================
29
30#include <QGridLayout>
31#include <QHeaderView>
32#include <QTableView>
33#include <QMouseEvent>
34#include <QSettings>
35
36//=============================================================================================================
37// USED NAMESPACES
38//=============================================================================================================
39
40using namespace DISPLIB;
41using namespace FIFFLIB;
42using namespace Eigen;
43
44//=============================================================================================================
45// DEFINE MEMBER METHODS
46//=============================================================================================================
47
48SpectrumView::SpectrumView(const QString& sSettingsPath,
49 QWidget* parent,
50 Qt::WindowFlags f)
51: AbstractView(parent, f)
52{
53 m_sSettingsPath = sSettingsPath;
54 m_pTableView = new QTableView;
55
56 m_pTableView->setSelectionMode(QAbstractItemView::ExtendedSelection);
57 m_pTableView->setMouseTracking(true);
58 m_pTableView->viewport()->installEventFilter(this);
59
60 //set vertical layout
61 QVBoxLayout* neLayout = new QVBoxLayout(this);
62
63 neLayout->addWidget(m_pTableView);
64
65 //set layouts
66 this->setLayout(neLayout);
68}
69
70//=============================================================================================================
71
76
77//=============================================================================================================
78
80 int iScaleType)
81{
83
84 m_pFSModel->setInfo(info);
85 m_pFSModel->setScaleType(iScaleType); /*Added by Limin; 10/19/2014 for passing the scale type to the model*/
86
88 m_pFSDelegate->setScaleType(iScaleType);
89
90 connect(m_pTableView.data(), &QTableView::doubleClicked,
92
93 // add a connection for sending mouse location to the delegate;
94 connect(this, &SpectrumView::sendMouseLoc,
96
97 m_pTableView->setModel(m_pFSModel);
98 m_pTableView->setItemDelegate(m_pFSDelegate);
99
100 //set some size settings for m_pTableView
101 m_pTableView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
102
103 m_pTableView->setShowGrid(false);
104
105 m_pTableView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); //Stretch 2 column to maximal width
106 m_pTableView->horizontalHeader()->hide();
107 m_pTableView->verticalHeader()->setDefaultSectionSize(140); //m_fZoomFactor*m_fDefaultSectionSize);//Row Height
108
109 m_pTableView->setAutoScroll(false);
110 m_pTableView->setColumnHidden(0, true); //because content is plotted jointly with column=1
111
112 m_pTableView->resizeColumnsToContents();
113
114 m_pTableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
115
116 //set context menu
117 m_pTableView->setContextMenuPolicy(Qt::CustomContextMenu);
118 //connect(m_pTableView,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(channelContextMenu(QPoint)));
119}
120
121//=============================================================================================================
122
123void SpectrumView::addData(const MatrixXd& matData)
124{
125 // The model is only created by init, and mne_scan pushes data through here
126 // as soon as a measurement arrives, which can be before init has run. There
127 // is nowhere to put the data in that case, so it is dropped rather than
128 // dereferencing a model that does not exist yet.
129 if (!m_pFSModel) {
130 return;
131 }
132
133 m_pFSModel->addData(matData);
134}
135
136//=============================================================================================================
137
139 int iUpper)
140{
141 // Same ordering as addData: the bounds can be set from a settings widget
142 // before the model exists.
143 if (!m_pFSModel) {
144 return;
145 }
146
147 m_pFSModel->setBoundaries(iLower, iUpper);
148}
149
150//=============================================================================================================
151
152bool SpectrumView::eventFilter(QObject* watched,
153 QEvent* event)
154{
155 if (event->type() == QEvent::MouseMove) {
156 QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
157 //qDebug()<<"MouseMove event!@"<<mouseEvent->x()<<":"<<mouseEvent->y();
158
159 int currentRow = m_pTableView->rowAt(static_cast<int>(mouseEvent->position().y()));
160 m_pTableView->selectRow(currentRow);
161
162 QModelIndex item = m_pTableView->currentIndex();
163
164 emit sendMouseLoc(item.row(), static_cast<int>(mouseEvent->position().x()), static_cast<int>(mouseEvent->position().y()), m_pTableView->visualRect(item));
165
166 return true;
167 } else {
168 return QWidget::eventFilter(watched, event);
169 }
170}
171
172//=============================================================================================================
173
175{
176 if (m_sSettingsPath.isEmpty()) {
177 return;
178 }
179
180 // Save Settings
181 QSettings settings("MNECPP");
182}
183
184//=============================================================================================================
185
187{
188 if (m_sSettingsPath.isEmpty()) {
189 return;
190 }
191
192 // Load Settings
193 QSettings settings("MNECPP");
194}
195
196//=============================================================================================================
197
199{
200 switch (mode) {
202 break;
203 default: // default is research mode
204 break;
205 }
206}
207
208//=============================================================================================================
209
211{
212 switch (mode) {
214 break;
215 default: // default is realtime mode
216 break;
217 }
218}
219
220//=============================================================================================================
221
223{
224}
Full FIFF measurement metadata: everything from FIFFB_MEAS / FIFFB_MEAS_INFO needed to interpret a re...
Per-channel frequency-spectrum heat-map TableView (rows = channels, columns = frequencies).
QAbstractItemDelegate painting one row of the DISPLIB::SpectrumView as a horizontal frequency band.
QAbstractTableModel storing per-channel FFT magnitudes for DISPLIB::SpectrumView.
FIFF file I/O, in-memory data structures and high-level readers/writers.
2-D display widgets and visualisation helpers (charts, topography, colour maps).
AbstractView(QWidget *parent=0, Qt::WindowFlags f=Qt::Widget)
QAbstractItemDelegate painting one SpectrumView row as a horizontal frequency band.
void rcvMouseLoc(int row, int x, int y, QRect visRect)
QAbstractTableModel storing per-channel FFT magnitudes for SpectrumView.
void toggleFreeze(const QModelIndex &index)
QPointer< QTableView > m_pTableView
QPointer< DISPLIB::FrequencySpectrumModel > m_pFSModel
void updateGuiMode(GuiMode mode)
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 addData(const Eigen::MatrixXd &matData)
void updateProcessingMode(ProcessingMode mode)
void sendMouseLoc(int row, int x, int y, QRect visRect)
QSharedPointer< FiffInfo > SPtr
Definition fiff_info.h:92