MNE-CPP  0.1.9
A Framework for Electrophysiology
data3Dtreedelegate.cpp
Go to the documentation of this file.
1 //=============================================================================================================
36 //=============================================================================================================
37 // INCLUDES
38 //=============================================================================================================
39 
40 #include "data3Dtreedelegate.h"
41 #include "../model/data3Dtreemodel.h"
42 
43 #include <disp/plots/imagesc.h>
44 #include <disp/plots/spline.h>
45 
46 #include <utils/mnemath.h>
47 
48 //=============================================================================================================
49 // QT INCLUDES
50 //=============================================================================================================
51 
52 #include <QSpinBox>
53 #include <QDoubleSpinBox>
54 #include <QComboBox>
55 #include <QPushButton>
56 #include <QDebug>
57 
58 //=============================================================================================================
59 // EIGEN INCLUDES
60 //=============================================================================================================
61 
62 //=============================================================================================================
63 // USED NAMESPACES
64 //=============================================================================================================
65 
66 using namespace UTILSLIB;
67 using namespace DISP3DLIB;
68 using namespace DISPLIB;
69 using namespace Eigen;
70 
71 //=============================================================================================================
72 // DEFINE MEMBER METHODS
73 //=============================================================================================================
74 
75 Data3DTreeDelegate::Data3DTreeDelegate(QObject* parent)
76 : QStyledItemDelegate(parent)
77 {
78 }
79 
80 //=============================================================================================================
81 
82 QWidget *Data3DTreeDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option , const QModelIndex& index) const
83 {
84  // Only create the editors here. Do not set any data from the model yet. This is done in setEditorData().
85  //Connect to Data3DTreeDelegate::onEditorEdited if you want to have immediate feedback (default by QItemDelegate is onEditorFinished).
86  const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model());
87  const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index));
88 
89  switch(pAbstractItem->type()) {
90  case MetaTreeItemTypes::SurfaceColorGyri: {
91  QColorDialog *pColorDialog = new QColorDialog(parent);
92  connect(pColorDialog, &QColorDialog::currentColorChanged,
93  this, &Data3DTreeDelegate::onEditorEdited);
94  pColorDialog->setWindowTitle("Select Gyri Color");
95  pColorDialog->show();
96  return pColorDialog;
97  }
98 
99  case MetaTreeItemTypes::SurfaceColorSulci: {
100  QColorDialog *pColorDialog = new QColorDialog(parent);
101  connect(pColorDialog, &QColorDialog::currentColorChanged,
102  this, &Data3DTreeDelegate::onEditorEdited);
103  pColorDialog->setWindowTitle("Select Sulci Color");
104  pColorDialog->show();
105  return pColorDialog;
106  }
107 
108  case MetaTreeItemTypes::ColormapType: {
109  QComboBox* pComboBox = new QComboBox(parent);
110  connect(pComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
111  this, &Data3DTreeDelegate::onEditorEdited);
112  pComboBox->addItem("HotNegative1");
113  pComboBox->addItem("HotNegative2");
114  pComboBox->addItem("Hot");
115  pComboBox->addItem("Jet");
116  pComboBox->addItem("RedBlue");
117  pComboBox->addItem("Bone");
118  pComboBox->addItem("Cool");
119  pComboBox->addItem("Viridis");
120  pComboBox->addItem("ViridisNegated");
121  return pComboBox;
122  }
123 
124  case MetaTreeItemTypes::DataThreshold: {
125  Spline* pSpline = new Spline(parent);
126  connect(pSpline, static_cast<void (Spline::*)(double, double, double)>(&Spline::borderChanged),
127  this, &Data3DTreeDelegate::onEditorEdited);
128  pSpline->setWindowFlags(Qt::Window);
129  pSpline->setWindowTitle("Set Threshold");
130  pSpline->show();
131  return pSpline;
132  }
133 
134  case MetaTreeItemTypes::StreamingTimeInterval: {
135  QSpinBox* pSpinBox = new QSpinBox(parent);
136  connect(pSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
137  this, &Data3DTreeDelegate::onEditorEdited);
138  pSpinBox->setSuffix(" mSec");
139  pSpinBox->setMinimum(1);
140  pSpinBox->setMaximum(50000);
141  pSpinBox->setSingleStep(1);
142  return pSpinBox;
143  }
144 
145  case MetaTreeItemTypes::VisualizationType: {
146  QComboBox* pComboBox = new QComboBox(parent);
147  pComboBox->addItem("Interpolation based");
148  pComboBox->addItem("Annotation based");
149  return pComboBox;
150  }
151 
152  case MetaTreeItemTypes::Color: {
153  QColorDialog *pColorDialog = new QColorDialog(parent);
154  connect(pColorDialog, &QColorDialog::currentColorChanged,
155  this, &Data3DTreeDelegate::onEditorEdited);
156  pColorDialog->setWindowTitle("Select Color");
157  pColorDialog->show();
158  return pColorDialog;
159  }
160 
161  case MetaTreeItemTypes::NumberAverages: {
162  QSpinBox* pSpinBox = new QSpinBox(parent);
163  connect(pSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
164  this, &Data3DTreeDelegate::onEditorEdited);
165  pSpinBox->setMinimum(1);
166  pSpinBox->setMaximum(100);
167  pSpinBox->setSingleStep(1);
168  return pSpinBox;
169  }
170 
171  case MetaTreeItemTypes::AlphaValue: {
172  QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent);
173  connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
174  this, &Data3DTreeDelegate::onEditorEdited);
175  pDoubleSpinBox->setMinimum(0.01);
176  pDoubleSpinBox->setMaximum(1.0);
177  pDoubleSpinBox->setSingleStep(0.01);
178  return pDoubleSpinBox;
179  }
180 
181  case MetaTreeItemTypes::SurfaceTessInner: {
182  QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent);
183  connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
184  this, &Data3DTreeDelegate::onEditorEdited);
185  pDoubleSpinBox->setMinimum(1.0);
186  pDoubleSpinBox->setMaximum(100.0);
187  pDoubleSpinBox->setSingleStep(1.0);
188  return pDoubleSpinBox;
189  }
190 
191  case MetaTreeItemTypes::SurfaceTessOuter: {
192  QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent);
193  connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
194  this, &Data3DTreeDelegate::onEditorEdited);
195  pDoubleSpinBox->setMinimum(1.0);
196  pDoubleSpinBox->setMaximum(100.0);
197  pDoubleSpinBox->setSingleStep(1.0);
198  return pDoubleSpinBox;
199  }
200 
201  case MetaTreeItemTypes::SurfaceTriangleScale: {
202  QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent);
203  connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)()>(&QDoubleSpinBox::editingFinished),
204  this, &Data3DTreeDelegate::onEditorEdited);
205  pDoubleSpinBox->setMinimum(0.01);
206  pDoubleSpinBox->setMaximum(100.0);
207  pDoubleSpinBox->setSingleStep(0.01);
208  return pDoubleSpinBox;
209  }
210 
211  case MetaTreeItemTypes::TranslateX: {
212  QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent);
213  connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
214  this, &Data3DTreeDelegate::onEditorEdited);
215  pDoubleSpinBox->setMinimum(-10000.0);
216  pDoubleSpinBox->setMaximum(10000.0);
217  pDoubleSpinBox->setSingleStep(0.001);
218  pDoubleSpinBox->setDecimals(5);
219  return pDoubleSpinBox;
220  }
221 
222  case MetaTreeItemTypes::TranslateY: {
223  QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent);
224  connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
225  this, &Data3DTreeDelegate::onEditorEdited);
226  pDoubleSpinBox->setMinimum(-10000.0);
227  pDoubleSpinBox->setMaximum(10000.0);
228  pDoubleSpinBox->setSingleStep(0.001);
229  pDoubleSpinBox->setDecimals(5);
230  return pDoubleSpinBox;
231  }
232 
233  case MetaTreeItemTypes::TranslateZ: {
234  QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent);
235  connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
236  this, &Data3DTreeDelegate::onEditorEdited);
237  pDoubleSpinBox->setMinimum(-10000.0);
238  pDoubleSpinBox->setMaximum(10000.0);
239  pDoubleSpinBox->setSingleStep(0.001);
240  pDoubleSpinBox->setDecimals(5);
241  return pDoubleSpinBox;
242  }
243 
244  case MetaTreeItemTypes::Scale: {
245  QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent);
246  connect(pDoubleSpinBox, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
247  this, &Data3DTreeDelegate::onEditorEdited);
248  pDoubleSpinBox->setMinimum(-10000.0);
249  pDoubleSpinBox->setMaximum(10000.0);
250  pDoubleSpinBox->setSingleStep(0.01);
251  pDoubleSpinBox->setDecimals(3);
252  return pDoubleSpinBox;
253  }
254 
255  case MetaTreeItemTypes::NetworkMatrix: {
256  if(AbstractTreeItem* pParentItem = static_cast<AbstractTreeItem*>(pAbstractItem->QStandardItem::parent())) {
257  QModelIndex indexParent = pData3DTreeModel->indexFromItem(pParentItem);
258  MatrixXd matRTData = index.model()->data(indexParent, Data3DTreeModelItemRoles::Data).value<MatrixXd>();
259 
260  ImageSc* pPlotLA = new ImageSc(matRTData, parent);
261  pPlotLA->resize(400,300);
262  pPlotLA->setWindowFlags(Qt::Window);
263  pPlotLA->show();
264 
265  QList<QStandardItem*> pColormapItem = pParentItem->findChildren(MetaTreeItemTypes::ColormapType);
266  for(int i = 0; i < pColormapItem.size(); ++i) {
267  if(pColormapItem.at(i)) {
268  QModelIndex indexColormapItem = pData3DTreeModel->indexFromItem(pColormapItem.at(i));
269  QString colorMap = index.model()->data(indexColormapItem, MetaTreeItemRoles::ColormapType).value<QString>();
270  pPlotLA->setColorMap(colorMap);
271  }
272  }
273  }
274  break;
275  //return pPlotLA;
276  }
277 
278  case MetaTreeItemTypes::MaterialType: {
279  QComboBox* pComboBox = new QComboBox(parent);
280  pComboBox->addItem("Phong Alpha Tesselation");
281  pComboBox->addItem("Phong Alpha");
282  pComboBox->addItem("Show normals");
283  pComboBox->addItem("GPU Interpolation");
284  return pComboBox;
285  }
286 
287  case MetaTreeItemTypes::CancelDistance: {
288  QDoubleSpinBox* pDoubleSpinBox = new QDoubleSpinBox(parent);
289  pDoubleSpinBox->setMinimum(0.001);
290  pDoubleSpinBox->setMaximum(1.0);
291  pDoubleSpinBox->setSingleStep(0.01);
292  pDoubleSpinBox->setSuffix("m");
293  return pDoubleSpinBox;
294  }
295 
296  case MetaTreeItemTypes::InterpolationFunction: {
297  QComboBox* pComboBox = new QComboBox(parent);
298  connect(pComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
299  this, &Data3DTreeDelegate::onEditorEdited);
300  pComboBox->addItem("Linear");
301  pComboBox->addItem("Square");
302  pComboBox->addItem("Cubic");
303  pComboBox->addItem("Gaussian");
304  return pComboBox;
305  }
306 
307  default: {
308  break;
309  }
310  }
311 
312  return QStyledItemDelegate::createEditor(parent, option, index);
313 }
314 
315 //=============================================================================================================
316 
317 void Data3DTreeDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
318 {
319  const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model());
320  const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index));
321 
322  // Only catch non-standard Qt types such as QColorDialog or items which need special handling for display role (e.g. Thresholding) etc.
323  switch(pAbstractItem->type()) {
324  case MetaTreeItemTypes::SurfaceColorGyri: {
325  QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColorGyri).value<QColor>();
326  QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
327  pColorDialog->setCurrentColor(color);
328  break;
329  }
330 
331  case MetaTreeItemTypes::SurfaceColorSulci: {
332  QColor color = index.model()->data(index, MetaTreeItemRoles::SurfaceColorSulci).value<QColor>();
333  QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
334  pColorDialog->setCurrentColor(color);
335  break;
336  }
337 
338  case MetaTreeItemTypes::Color: {
339  QColor color = index.model()->data(index, MetaTreeItemRoles::Color).value<QColor>();
340  QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
341  pColorDialog->setCurrentColor(color);
342  break;
343  }
344 
345  case MetaTreeItemTypes::DataThreshold: {
346  if(Spline* pSpline = static_cast<Spline*>(editor)) {
347  //Find the parent and retreive real-time data to calcualte the histogram
348  if(AbstractTreeItem* pParentItem = static_cast<AbstractTreeItem*>(pAbstractItem->QStandardItem::parent())) {
349  QModelIndex indexParent = pData3DTreeModel->indexFromItem(pParentItem);
350 
351  //Get data
352  MatrixXd matRTData;
353  QVariant data;
354 
355  data = index.model()->data(indexParent, Data3DTreeModelItemRoles::Data);
356 
357  if(data.canConvert<MatrixXd>()) {
358  matRTData = data.value<MatrixXd>();
359  matRTData = matRTData.cwiseAbs();
360 
361  //Calcualte histogram
362  Eigen::VectorXd resultClassLimit;
363  Eigen::VectorXi resultFrequency;
364  MNEMath::histcounts(matRTData, false, 50, resultClassLimit, resultFrequency, 0.0, 0.0);
365 
366  //Create histogram plot
367  pSpline->setData(resultClassLimit, resultFrequency);
368  QVector3D vecThresholdValues = index.model()->data(index, MetaTreeItemRoles::DataThreshold).value<QVector3D>();
369  pSpline->setThreshold(vecThresholdValues);
370 
371  QList<QStandardItem*> pColormapItem = pParentItem->findChildren(MetaTreeItemTypes::ColormapType);
372  for(int i = 0; i < pColormapItem.size(); ++i) {
373  if(pColormapItem.at(i)) {
374  QModelIndex indexColormapItem = pData3DTreeModel->indexFromItem(pColormapItem.at(i));
375  QString colorMap = index.model()->data(indexColormapItem, MetaTreeItemRoles::ColormapType).value<QString>();
376  pSpline->setColorMap(colorMap);
377  }
378  }
379  }
380  }
381 
382  pSpline->resize(600,400);
383  pSpline->show();
384  }
385 
386  break;
387  }
388 
389  // Handle basic types (QString, int, double, etc.) by default via QItemDelegate::setEditorData
390  default: {
391  QStyledItemDelegate::setEditorData(editor, index);
392  }
393  }
394 }
395 
396 //=============================================================================================================
397 
398 void Data3DTreeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
399 {
400  const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model());
401  const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index));
402 
403  //Set data manually here so we can use our own item roles.
404  switch(pAbstractItem->type()) {
405  case MetaTreeItemTypes::SurfaceColorGyri: {
406  QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
407  QColor color = pColorDialog->currentColor();
408  QVariant data;
409  data.setValue(color);
410 
411  model->setData(index, data, MetaTreeItemRoles::SurfaceColorGyri);
412  model->setData(index, data, Qt::DecorationRole);
413  break;
414  }
415 
416  case MetaTreeItemTypes::SurfaceColorSulci: {
417  QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
418  QColor color = pColorDialog->currentColor();
419  QVariant data;
420  data.setValue(color);
421 
422  model->setData(index, data, MetaTreeItemRoles::SurfaceColorSulci);
423  model->setData(index, data, Qt::DecorationRole);
424  break;
425  }
426 
427  case MetaTreeItemTypes::ColormapType: {
428  QComboBox* pColorMapType = static_cast<QComboBox*>(editor);
429  QVariant data;
430  data.setValue(pColorMapType->currentText());
431 
432  model->setData(index, data, MetaTreeItemRoles::ColormapType);
433  model->setData(index, data, Qt::DisplayRole);
434  break;
435  }
436 
437  case MetaTreeItemTypes::DataThreshold: {
438  if(Spline* pSpline = static_cast<Spline*>(editor)) {
439  QVector3D returnVector;
440  returnVector = pSpline->getThreshold();
441 
442  QString displayThreshold;
443  displayThreshold = QString("%1,%2,%3").arg(returnVector.x()).arg(returnVector.y()).arg(returnVector.z());
444  QVariant data;
445  data.setValue(displayThreshold);
446  model->setData(index, data, Qt::DisplayRole);
447  data.setValue(returnVector);
448  model->setData(index, data, MetaTreeItemRoles::DataThreshold);
449  }
450  break;
451  }
452 
453  case MetaTreeItemTypes::StreamingTimeInterval: {
454  QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);
455 
456  QVariant data;
457  data.setValue(pSpinBox->value());
458 
459  model->setData(index, data, MetaTreeItemRoles::StreamingTimeInterval);
460  model->setData(index, data, Qt::DisplayRole);
461  break;
462  }
463 
464  case MetaTreeItemTypes::VisualizationType: {
465  QComboBox* pVisType = static_cast<QComboBox*>(editor);
466  QVariant data;
467  data.setValue(pVisType->currentText());
468 
469  model->setData(index, data, MetaTreeItemRoles::VisualizationType);
470  model->setData(index, data, Qt::DisplayRole);
471  break;
472  }
473 
474  case MetaTreeItemTypes::Color: {
475  QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
476  QColor color = pColorDialog->currentColor();
477  QVariant data;
478  data.setValue(color);
479 
480  model->setData(index, data, MetaTreeItemRoles::Color);
481  model->setData(index, data, Qt::DecorationRole);
482  break;
483  }
484 
485  case MetaTreeItemTypes::NumberAverages: {
486  QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);
487 
488  QVariant data;
489  data.setValue(pSpinBox->value());
490 
491  model->setData(index, data, MetaTreeItemRoles::NumberAverages);
492  model->setData(index, data, Qt::DisplayRole);
493  break;
494  }
495 
496  case MetaTreeItemTypes::AlphaValue: {
497  QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
498  QVariant data;
499  data.setValue(pDoubleSpinBox->value());
500 
501  model->setData(index, data, MetaTreeItemRoles::AlphaValue);
502  model->setData(index, data, Qt::DisplayRole);
503  break;
504  }
505 
506  case MetaTreeItemTypes::SurfaceTessInner: {
507  QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
508  QVariant data;
509  data.setValue(pDoubleSpinBox->value());
510 
511  model->setData(index, data, MetaTreeItemRoles::SurfaceTessInner);
512  model->setData(index, data, Qt::DisplayRole);
513  break;
514  }
515 
516  case MetaTreeItemTypes::SurfaceTessOuter: {
517  QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
518  QVariant data;
519  data.setValue(pDoubleSpinBox->value());
520 
521  model->setData(index, data, MetaTreeItemRoles::SurfaceTessOuter);
522  model->setData(index, data, Qt::DisplayRole);
523  break;
524  }
525 
526  case MetaTreeItemTypes::SurfaceTriangleScale: {
527  QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
528  QVariant data;
529  data.setValue(pDoubleSpinBox->value());
530 
531  model->setData(index, data, MetaTreeItemRoles::SurfaceTriangleScale);
532  model->setData(index, data, Qt::DisplayRole);
533  break;
534  }
535 
536  case MetaTreeItemTypes::TranslateX: {
537  QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
538  QVariant data;
539  data.setValue(pDoubleSpinBox->value());
540 
541  model->setData(index, data, MetaTreeItemRoles::TranslateX);
542  model->setData(index, data, Qt::DisplayRole);
543  break;
544  }
545 
546  case MetaTreeItemTypes::TranslateY: {
547  QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
548  QVariant data;
549  data.setValue(pDoubleSpinBox->value());
550 
551  model->setData(index, data, MetaTreeItemRoles::TranslateY);
552  model->setData(index, data, Qt::DisplayRole);
553  break;
554  }
555 
556  case MetaTreeItemTypes::TranslateZ: {
557  QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
558  QVariant data;
559  data.setValue(pDoubleSpinBox->value());
560 
561  model->setData(index, data, MetaTreeItemRoles::TranslateZ);
562  model->setData(index, data, Qt::DisplayRole);
563  break;
564  }
565 
566  case MetaTreeItemTypes::Scale: {
567  QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
568  QVariant data;
569  data.setValue(pDoubleSpinBox->value());
570 
571  model->setData(index, data, MetaTreeItemRoles::Scale);
572  model->setData(index, data, Qt::DisplayRole);
573  break;
574  }
575 
576  case MetaTreeItemTypes::MaterialType: {
577  QComboBox* pComboBox = static_cast<QComboBox*>(editor);
578  QVariant data;
579  data.setValue(pComboBox->currentText());
580 
581  model->setData(index, data, MetaTreeItemRoles::SurfaceMaterial);
582  model->setData(index, data, Qt::DisplayRole);
583  break;
584  }
585 
586  case MetaTreeItemTypes::CancelDistance: {
587  QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
588  QVariant data;
589  data.setValue(pDoubleSpinBox->value());
590 
591  model->setData(index, data, MetaTreeItemRoles::CancelDistance);
592  model->setData(index, data, Qt::DisplayRole);
593  break;
594  }
595 
596  case MetaTreeItemTypes::InterpolationFunction: {
597  QComboBox* pColorMapType = static_cast<QComboBox*>(editor);
598  QVariant data;
599  data.setValue(pColorMapType->currentText());
600 
601  model->setData(index, data, MetaTreeItemRoles::InterpolationFunction);
602  model->setData(index, data, Qt::DisplayRole);
603  break;
604  }
605 
606  // Handle all other item types via QItemDelegate::setModelData handling
607  default: {
608  QStyledItemDelegate::setModelData(editor, model, index);
609  break;
610  }
611  }
612 }
613 
614 //=============================================================================================================
615 
616 void Data3DTreeDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem &option, const QModelIndex& index) const
617 {
618  QStyledItemDelegate::updateEditorGeometry(editor, option, index);
619  //editor->setGeometry(option.rect);
620 }
621 
622 //=============================================================================================================
623 
624 void Data3DTreeDelegate::onEditorEdited()
625 {
626  if(QWidget* editor = qobject_cast<QWidget*>(QObject::sender())) {
627  emit commitData(editor);
628  }
629 }
630 
Data3DTreeDelegate class declaration.
ImageSc class declaration.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Spline class for histogram display using Qtcharts/QSpline.
Definition: spline.h:85
void setData(const QVariant &value, int role=Qt::UserRole+1)
Data3DTreeModel provides a tree based data model to hold all information about data which was added t...
Provides the basic tree item.
MNEMath class declaration.
Eigen matrix visualization.
Definition: imagesc.h:77
Spline class declaration.