Computer Assited Medical Intervention Tool Kit  version 4.1
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-2018 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 #include "MeshComponent.h"
33 
34 namespace camitk {
35 
45 class MeshDataModel : public QAbstractTableModel {
46 
47  Q_OBJECT
48 
49 public :
50 
54  MeshDataModel(MeshComponent* meshComp);
55 
59  int rowCount(const QModelIndex& parent = QModelIndex()) const ;
60 
64  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
65 
69  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
70 
74  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
75 
79  bool setData(const QModelIndex& index, const QVariant& value, int role) override;
80 
83  Qt::ItemFlags flags(const QModelIndex& index) const override;
84 
88  void refresh();
89 
90 private :
91 
94 
97  void getRowInfo(const int, int* dataIndex, MeshComponent::FieldType*, MeshComponent::DataType*, QString&) const;
98 
99 };
100 
101 // -----------------------------------------------------
102 
108 class MeshDataFilterModel : public QSortFilterProxyModel {
109 
110  Q_OBJECT
111 
112 public :
113 
116  QObject* parent = nullptr);
117 
118  void setFieldTypeFilter(int fieldFilter);
119 
120  void setDataTypeFilter(int dataFilter);
121 
122 protected :
123 
124  bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
125 
126 private :
127 
129 
131 
132 };
133 
134 }
135 
136 #endif
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns if a given model index is editable, checkable....
Definition: MeshDataModel.cpp:214
MeshComponent * meshComponent
The component where the data are stored.
Definition: MeshDataModel.h:93
int fieldTypeFilter
Definition: MeshDataModel.h:128
3D (3D vector)
Definition: MeshComponent.h:60
CamiTK intern class to help automatically sort or show specific data.
Definition: MeshDataModel.h:108
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Number of data arrays columns.
Definition: MeshDataModel.cpp:55
data are attached to point
Definition: MeshComponent.h:67
void getRowInfo(const int, int *dataIndex, MeshComponent::FieldType *, MeshComponent::DataType *, QString &) const
determine the current field type of the item depending on the row index, compute the index of the dat...
Definition: MeshDataModel.cpp:60
int dataTypeFilter
Definition: MeshDataModel.h:130
Qt model for mesh data.
Definition: MeshDataModel.h:45
1D (scalar value)
Definition: MeshComponent.h:59
Definition: Action.cpp:36
Basic component to manage any kind of mesh.
Definition: MeshComponent.h:53
int rowCount(const QModelIndex &parent=QModelIndex()) const
Number of data arrays.
Definition: MeshDataModel.cpp:45
data are attached to cells
Definition: MeshComponent.h:68
bool setData(const QModelIndex &index, const QVariant &value, int role) override
Edit data, called when the data are modified by the user (view)
Definition: MeshDataModel.cpp:186
DataType
Data fields can have different dimensions.
Definition: MeshComponent.h:58
void refresh()
Refresh the model.
Definition: MeshDataModel.cpp:252
9D (3x3 matrix)
Definition: MeshComponent.h:61
other dimensions (warning: nothing special are managed by this class, no specific interaction) ...
Definition: MeshComponent.h:62
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Model data, called when the view is refreshing visualization.
Definition: MeshDataModel.cpp:91
data are attached to the whole mesh (generic field data of Vtk)
Definition: MeshComponent.h:69
MeshDataModel(MeshComponent *meshComp)
Constructor.
Definition: MeshDataModel.cpp:38
FieldType
Data fields can be applied to one of this.
Definition: MeshComponent.h:66
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Header data.
Definition: MeshDataModel.cpp:225