Computer Assited Medical Intervention Tool Kit  version 4.0
MeshDataModel.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2016 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef MESH_DATA_MODEL_H
27 #define MESH_DATA_MODEL_H
28 
29 #include <QAbstractTableModel>
30 #include <QSortFilterProxyModel>
31 
32 namespace camitk {
33 
34 class MeshComponent;
35 
40 class MeshDataModel : public QAbstractTableModel {
41 
42  Q_OBJECT
43 
44 public :
45 
47  enum FieldType {
48  POINTS = 1,
49  CELLS = 2,
50  MESH = 4
51  };
52 
54  enum DataType {
55  SCALARS = 1,
56  VECTORS = 2,
57  TENSORS = 4,
58  OTHERS = 8
59  };
60 
64  MeshDataModel ( MeshComponent* meshComp );
65 
69  int rowCount ( const QModelIndex &parent = QModelIndex() ) const ;
70 
74  int columnCount ( const QModelIndex &parent = QModelIndex() ) const;
75 
79  QVariant data ( const QModelIndex &index, int role = Qt::DisplayRole ) const;
80 
84  QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
85 
89  bool setData ( const QModelIndex &index, const QVariant &value, int role );
90 
93  Qt::ItemFlags flags ( const QModelIndex &index ) const;
94 
96  static const QMap< int, QString >& getFieldNames();
97 
99  static const QMap< int, QString >& getDataNames();
100 
104  void refresh();
105 
106 private :
107 
110 
112  static QMap< int, QString > initFieldNames();
113 
115  static QMap< int, QString > initDataNames();
116 
118  FieldType getFieldTypeOfRow(const int, int *dataIndex) const;
119 
120 };
121 
122 class MeshDataFilterModel : public QSortFilterProxyModel {
123 
124  Q_OBJECT
125 
126 public :
127 
130  QObject* parent = NULL);
131 
132  void setFieldTypeFilter(int fieldFilter);
133 
134  void setDataTypeFilter(int dataFilter);
135 
136 protected :
137 
138  bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
139 
140 private :
141 
143 
145 
146 };
147 
148 }
149 
150 #endif
DataType
Data fields can have different dimensions.
Definition: MeshDataModel.h:54
MeshComponent * meshComponent
The component where the data are stored.
Definition: MeshDataModel.h:109
int fieldTypeFilter
Definition: MeshDataModel.h:142
static const QMap< int, QString > & getFieldNames()
static method that returns the FieldType enum as a QString
Definition: MeshDataModel.cpp:313
1D (scalar value)
Definition: MeshDataModel.h:55
Definition: MeshDataModel.h:122
3D (3D vector)
Definition: MeshDataModel.h:56
9D (3x3 matrix)
Definition: MeshDataModel.h:57
int dataTypeFilter
Definition: MeshDataModel.h:144
Qt model for mesh data.
Definition: MeshDataModel.h:40
bool setData(const QModelIndex &index, const QVariant &value, int role)
Edit data, called when the data are modified by the user (view)
Definition: MeshDataModel.cpp:219
Definition: Action.cpp:40
Basic component to manage any kind of mesh.
Definition: MeshComponent.h:51
int rowCount(const QModelIndex &parent=QModelIndex()) const
Number of data arrays.
Definition: MeshDataModel.cpp:43
static const QMap< int, QString > & getDataNames()
static method that returns the DataType enum as a QString
Definition: MeshDataModel.cpp:319
static QMap< int, QString > initFieldNames()
initialize FieldType QString map
Definition: MeshDataModel.cpp:325
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Header data.
Definition: MeshDataModel.cpp:283
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Model data, called when the view is refreshing visualization.
Definition: MeshDataModel.cpp:74
FieldType getFieldTypeOfRow(const int, int *dataIndex) const
determine the current field type of the item depending on the row index, compute the index of the dat...
Definition: MeshDataModel.cpp:57
other dimensions (warning: nothing special are managed by this class, no specific interaction) ...
Definition: MeshDataModel.h:58
Qt::ItemFlags flags(const QModelIndex &index) const
Returns if a given model index is editable, checkable....
Definition: MeshDataModel.cpp:274
void refresh()
Refresh the model.
Definition: MeshDataModel.cpp:309
int columnCount(const QModelIndex &parent=QModelIndex()) const
Number of data arrays columns.
Definition: MeshDataModel.cpp:52
data are attached to point
Definition: MeshDataModel.h:48
data are attached to cells
Definition: MeshDataModel.h:49
static QMap< int, QString > initDataNames()
initialize DataType QString map
Definition: MeshDataModel.cpp:334
FieldType
Data fields can be applied to one of this.
Definition: MeshDataModel.h:47
data are attached to the whole mesh
Definition: MeshDataModel.h:50
MeshDataModel(MeshComponent *meshComp)
Constructor.
Definition: MeshDataModel.cpp:36