MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
control3dview.cpp
Go to the documentation of this file.
1//=============================================================================================================
35//=============================================================================================================
36// INCLUDES
37//=============================================================================================================
38
39#include "ui_control3dview.h"
40#include "control3dview.h"
41
42//=============================================================================================================
43// QT INCLUDES
44//=============================================================================================================
45
46#include <QMenu>
47#include <QSettings>
48#include <QMessageBox>
49
50//=============================================================================================================
51// EIGEN INCLUDES
52//=============================================================================================================
53
54//=============================================================================================================
55// QT INCLUDES
56//=============================================================================================================
57
58#include <QStyledItemDelegate>
59#include <QStandardItemModel>
60#include <QColorDialog>
61
62//=============================================================================================================
63// USED NAMESPACES
64//=============================================================================================================
65
66using namespace DISPLIB;
67
68//=============================================================================================================
69// DEFINE MEMBER METHODS
70//=============================================================================================================
71
72Control3DView::Control3DView(const QString& sSettingsPath,
73 QWidget* parent,
74 const QStringList& slFlags,
75 Qt::WindowType type)
76: AbstractView(parent, type)
77, m_pUi(new Ui::Control3DViewWidget)
78, m_colCurrentSceneColor(QColor(0,0,0))
79, m_colCurrentLightColor(QColor(255,255,255))
80{
81 m_sSettingsPath = sSettingsPath;
82 m_pUi->setupUi(this);
83
84 setFlags(slFlags);
85
86 //Init's
87 m_pUi->m_pushButton_sceneColorPicker->setStyleSheet(QString("background-color: rgb(0, 0, 0);"));
88 m_pUi->m_pushButton_lightColorPicker->setStyleSheet(QString("background-color: rgb(255, 255, 255);"));
89
90 this->adjustSize();
91
92 //set context menu
93 m_pUi->m_treeView_loadedData->setContextMenuPolicy(Qt::CustomContextMenu);
94 connect(m_pUi->m_treeView_loadedData, &QWidget::customContextMenuRequested,
96
98}
99
100//=============================================================================================================
101
103{
104 saveSettings();
105 delete m_pUi;
106}
107
108//=============================================================================================================
109
110void Control3DView::setFlags(const QStringList& slFlags)
111{
112 //Parse flags
113 if(slFlags.contains("Data")) {
114 m_pUi->m_treeView_loadedData->show();
115 } else {
116 m_pUi->m_treeView_loadedData->hide();
117 }
118
119 if(slFlags.contains("View")) {
120 m_pUi->m_groupBox_viewOptions->show();
121
122 connect(m_pUi->m_pushButton_sceneColorPicker, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
124 connect(m_pUi->m_checkBox_showFullScreen, &QCheckBox::clicked,
126
127 connect(m_pUi->m_checkBox_rotate, &QCheckBox::clicked,
129
130 connect(m_pUi->m_checkBox_coordAxis, &QCheckBox::clicked,
132
133 connect(m_pUi->m_pushButton_takeScreenshot, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
135
136 connect(m_pUi->m_radioButton_single, &QRadioButton::pressed,
138
139 connect(m_pUi->m_radioButton_multi, &QRadioButton::pressed,
141 } else {
142 m_pUi->m_groupBox_viewOptions->hide();
143 }
144
145 if(slFlags.contains("Light")) {
146 m_pUi->m_groupBox_lightOptions->show();
147
148 connect(m_pUi->m_pushButton_lightColorPicker, static_cast<void (QPushButton::*)(bool)>(&QPushButton::clicked),
150 connect(m_pUi->m_doubleSpinBox_colorIntensity, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
152 } else {
153 m_pUi->m_groupBox_lightOptions->hide();
154 }
155}
156
157//=============================================================================================================
158
159void Control3DView::setDelegate(QStyledItemDelegate *pItemDelegate)
160{
161 //Init tree view properties
162 m_pUi->m_treeView_loadedData->setItemDelegate(pItemDelegate);
163 m_pUi->m_treeView_loadedData->setHeaderHidden(false);
164 m_pUi->m_treeView_loadedData->setEditTriggers(QAbstractItemView::CurrentChanged);
165}
166
167//=============================================================================================================
168
169void Control3DView::setModel(QStandardItemModel* pDataTreeModel)
170{
171 //Do the connects from this control widget to the View3D
172 m_pUi->m_treeView_loadedData->setModel(pDataTreeModel);
173
174 //Set description hidden as default
175 //m_pUi->m_treeView_loadedData->setColumnHidden(1, true);
176}
177
178//=============================================================================================================
179
181{
182 if(!m_pUi->m_treeView_loadedData->isHeaderHidden()) {
183 m_pUi->m_treeView_loadedData->setHeaderHidden(true);
184 } else {
185 m_pUi->m_treeView_loadedData->setHeaderHidden(false);
186 }
187}
188
189//=============================================================================================================
190
191void Control3DView::onTreeViewRemoveItem(const QModelIndex& index)
192{
193 if(index.isValid()) {
194 m_pUi->m_treeView_loadedData->model()->removeRow(index.row(), index.parent());
195 }
196}
197
198//=============================================================================================================
199
201{
202 if(m_pUi->m_treeView_loadedData->isColumnHidden(1)) {
203 m_pUi->m_treeView_loadedData->setColumnHidden(1, false);
204 } else {
205 m_pUi->m_treeView_loadedData->setColumnHidden(1, true);
206 }
207}
208
209//=============================================================================================================
210
212{
213 if(m_sSettingsPath.isEmpty()) {
214 return;
215 }
216
217 // Save Settings
218 QSettings settings("MNECPP");
219}
220
221//=============================================================================================================
222
224{
225 if(m_sSettingsPath.isEmpty()) {
226 return;
227 }
228
229 // Load Settings
230 QSettings settings("MNECPP");
231}
232
233//=============================================================================================================
234
236{
237 switch(mode) {
238 case GuiMode::Clinical:
239 break;
240 default: // default is research mode
241 break;
242 }
243}
244
245//=============================================================================================================
246
247void Control3DView::updateProcessingMode(ProcessingMode mode)
248{
249 switch(mode) {
250 case ProcessingMode::Offline:
251 break;
252 default: // default is realtime mode
253 break;
254 }
255}
256
257//=============================================================================================================
258
260{
261 this->setWindowOpacity(1/(100.0/value));
262}
263
264//=============================================================================================================
265
267{
268 QColorDialog* pDialog = new QColorDialog(this);
269 pDialog->setCurrentColor(m_colCurrentSceneColor);
270
271 //Update all connected View3D's scene colors
272 connect(pDialog, &QColorDialog::currentColorChanged,
274
275 pDialog->exec();
276 m_colCurrentSceneColor = pDialog->currentColor();
277
278 //Set color of button new new scene color
279 m_pUi->m_pushButton_sceneColorPicker->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(m_colCurrentSceneColor.red()).arg(m_colCurrentSceneColor.green()).arg(m_colCurrentSceneColor.blue()));
280}
281
282//=============================================================================================================
283
285{
286 //create custom context menu and actions
287 QMenu *menu = new QMenu(this);
288
289 // Hide header
290 QAction* pHideHeader = menu->addAction(tr("Toggle header"));
291 connect(pHideHeader, &QAction::triggered,
293
294 // Remove item
295 QAction* pRemoveItem = menu->addAction(tr("Remove"));
296 connect(pRemoveItem, &QAction::triggered, [=]() {
297 if (QMessageBox::question(this,
298 tr("Remove item"),
299 tr("Are you sure you want to delete the item?")) == QMessageBox::Yes) {
300 onTreeViewRemoveItem(m_pUi->m_treeView_loadedData->indexAt(pos));
301 }
302 });
303
304// QAction* pHideDesc = menu->addAction(tr("Toggle description"));
305// connect(pHideDesc, &QAction::triggered,
306// this, &Control3DView::onTreeViewDescriptionHide);
307
308 //show context menu
309 menu->popup(m_pUi->m_treeView_loadedData->viewport()->mapToGlobal(pos));
310}
311
312//=============================================================================================================
313
315{
316 if(state) {
317 this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
318 this->show();
319 } else {
320 this->setWindowFlags(this->windowFlags() & ~Qt::WindowStaysOnTopHint);
321 this->show();
322 }
323}
324
325//=============================================================================================================
326
327void Control3DView::onSceneColorChanged(const QColor& color)
328{
329 emit sceneColorChanged(color);
330}
331
332//=============================================================================================================
333
335{
336 emit showFullScreen(checked);
337}
338
339//=============================================================================================================
340
342{
343 emit rotationChanged(checked);
344}
345
346//=============================================================================================================
347
349{
350 emit showCoordAxis(checked);
351}
352
353//=============================================================================================================
354
356{
357 QColorDialog* pDialog = new QColorDialog(this);
358 pDialog->setCurrentColor(m_colCurrentLightColor);
359
360 //Update all connected View3D's scene colors
361 connect(pDialog, &QColorDialog::currentColorChanged,
363
364 pDialog->exec();
365 m_colCurrentLightColor = pDialog->currentColor();
366
367 //Set color of button new new scene color
368 m_pUi->m_pushButton_lightColorPicker->setStyleSheet(QString("background-color: rgb(%1, %2, %3);").arg(m_colCurrentLightColor.red()).arg(m_colCurrentLightColor.green()).arg(m_colCurrentLightColor.blue()));
369}
370
371//=============================================================================================================
372
373void Control3DView::onLightColorChanged(const QColor &color)
374{
375 emit lightColorChanged(color);
376}
377
378//=============================================================================================================
379
381{
382 emit lightIntensityChanged(value);
383}
384
385//=============================================================================================================
386
388{
389
390}
Control3DView class declaration.
The AbstractView class provides the base calss for all Disp viewers.
void setDelegate(QStyledItemDelegate *pItemDelegate)
void sceneColorChanged(const QColor &color)
Control3DView(const QString &sSettingsPath="", QWidget *parent=0, const QStringList &slFlags=QStringList()<< "Data"<< "View"<< "Light", Qt::WindowType type=Qt::Widget)
void showFullScreen(bool bShowFullScreen)
void onSceneColorChanged(const QColor &color)
void setFlags(const QStringList &slFlags)
void onOpacityChange(qint32 value)
void rotationChanged(bool bRotationChanged)
void updateGuiMode(GuiMode mode)
void onCoordAxisClicked(bool checked)
void onCustomContextMenuRequested(QPoint pos)
customContextMenuRequested
void updateProcessingMode(ProcessingMode mode)
void onTreeViewRemoveItem(const QModelIndex &index)
void lightIntensityChanged(double value)
Ui::Control3DViewWidget * m_pUi
void onRotationClicked(bool checked)
void onShowFullScreen(bool checked)
void showCoordAxis(bool bShowCoordAxis)
void onAlwaysOnTop(bool state)
void lightColorChanged(const QColor &color)
void onLightColorChanged(const QColor &color)
void setModel(QStandardItemModel *pDataTreeModel)
void onLightIntensityChanged(double value)