MNE-CPP  beta 1.0
cluststctabledelegate.cpp
Go to the documentation of this file.
1 //=============================================================================================================
37 //*************************************************************************************************************
38 //=============================================================================================================
39 // INCLUDES
40 //=============================================================================================================
41 
42 #include "cluststctabledelegate.h"
43 #include "cluststcmodel.h" //Declar MetaType Eigen::Matrix3Xf; FSLIB::Label
44 
45 
46 //*************************************************************************************************************
47 //=============================================================================================================
48 // Qt INCLUDES
49 //=============================================================================================================
50 
51 #include <QPainter>
52 #include <QDebug>
53 
54 
55 //*************************************************************************************************************
56 //=============================================================================================================
57 // USED NAMESPACES
58 //=============================================================================================================
59 
60 using namespace DISP3DLIB;
61 using namespace Eigen;
62 
63 
64 //*************************************************************************************************************
65 //=============================================================================================================
66 // DEFINE MEMBER METHODS
67 //=============================================================================================================
68 
69 ClustStcTableDelegate::ClustStcTableDelegate(QObject *parent)
70 : QAbstractItemDelegate(parent)
71 {
72 }
73 
74 //*************************************************************************************************************
75 
76 void ClustStcTableDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
77 {
78 // float t_fPlotHeight = option.rect.height();
79  switch(index.column()) {
80  case 0: { //index
81  painter->save();
82 
83  painter->drawText(option.rect,Qt::AlignVCenter|Qt::AlignLeft,index.model()->data(index,Qt::DisplayRole).toString());
84 
85  painter->restore();
86  break;
87  }
88  case 1: { //vertex
89  painter->save();
90 
91  painter->drawText(option.rect,Qt::AlignVCenter|Qt::AlignLeft,index.model()->data(index,Qt::DisplayRole).toString());
92 
93  painter->restore();
94  break;
95  }
96  case 2: { //stc value
97  painter->save();
98 
99  qint32 val = index.model()->data(index,Qt::DisplayRole).value<VectorXd>().size();
100  painter->drawText(option.rect,Qt::AlignVCenter|Qt::AlignLeft,QString("%1").arg(val));
101 
102  painter->restore();
103  break;
104  }
105  case 3: { //stc relative value
106  painter->save();
107 
108  qint32 val = index.model()->data(index,Qt::DisplayRole).value<VectorXd>().size();
109  painter->drawText(option.rect,Qt::AlignVCenter|Qt::AlignLeft,QString("%1").arg(val));
110 
111  painter->restore();
112  break;
113  }
114  case 4: { //Label
115  painter->save();
116 
117  painter->drawText(option.rect,Qt::AlignVCenter|Qt::AlignLeft,index.model()->data(index,Qt::DisplayRole).value<Label>().name);
118 
119  painter->restore();
120  break;
121  }
122  case 5: { //Color
123  painter->save();
124 
125  QColor c = index.model()->data(index,Qt::DisplayRole).value<QColor>();
126 
127  painter->setPen(c);
128  painter->drawText(option.rect,Qt::AlignVCenter|Qt::AlignLeft,c.name());
129 
130  painter->restore();
131  break;
132  }
133  case 6: { //Tri Coords
134  painter->save();
135 
136  painter->drawText(option.rect,Qt::AlignVCenter|Qt::AlignLeft,QString("%1").arg(index.model()->data(index,Qt::DisplayRole).value<Matrix3Xf>().cols()));
137 
138  painter->restore();
139  break;
140  }
141  }
142 
143 }
144 
145 
146 //*************************************************************************************************************
147 
148 QSize ClustStcTableDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
149 {
150  QSize size;
151 
152  switch(index.column()) {
153  case 0:
154  size = QSize(20,option.rect.height());
155  break;
156  case 1:
157  size = QSize(10,option.rect.height());
158  break;
159  }
160 
161  return size;
162 }
ClustStcModel class declaration.
ClustStcTableDelegate class declaration.
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Freesurfer/MNE label.
Definition: label.h:97