Commit 7dbd6154 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED cleaner code for MeshDataModel

Divide and conquer / easier to undestand / easier to maintain...
parent 68b107dd
......@@ -875,6 +875,25 @@ MeshDataModel* MeshComponent::getDataModel() {
return dataModel;
}
// -------------------- getFieldData --------------------
vtkSmartPointer<vtkFieldData> MeshComponent::getFieldData(MeshDataModel::FieldType fieldType) {
switch (fieldType) {
case MeshDataModel::POINTS:
return getPointSet()->GetPointData();
break;
case MeshDataModel::CELLS:
return getPointSet()->GetCellData();
break;
case MeshDataModel::MESH:
default:
return getPointSet()->GetFieldData();
break;
}
}
// -------------------- removeSelectedData --------------------
void MeshComponent::removeSelectedData() {
// TODO : handle multiple selection and cell/mesh data array deletion
......
......@@ -303,12 +303,15 @@ public:
*/
void setActiveData(MeshDataModel::FieldType fieldType, const char* name);
/// Return the current value of the display type selected by the user
/// Returns the current value of the display type selected by the user
MeshDataModel::DisplayTypeFor3DData getCurrentDisplayTypePolicy() const;
/// get the current data view model (model as the M in Qt MVC design pattern)
/// Returns the current data view model (model as the M in Qt MVC design pattern)
MeshDataModel* getDataModel();
/// Returns the corresponding vtkFieldData (point data, cell data or field data)
vtkSmartPointer<vtkFieldData> getFieldData(MeshDataModel::FieldType);
/**
* @}
*/
......
......@@ -29,6 +29,9 @@
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
#include <vtkSmartPointer.h>
class vtkDataArray;
namespace camitk {
class MeshComponent;
......@@ -52,7 +55,7 @@ public :
enum FieldType {
POINTS = 1, ///< data are attached to point
CELLS = 2, ///< data are attached to cells
MESH = 4 ///< data are attached to the whole mesh
MESH = 4 ///< data are attached to the whole mesh (generic field data of Vtk)
};
/// @enum DataType Data fields can have different dimensions
......@@ -110,9 +113,27 @@ public :
/// static method that returns the FieldType enum as a QString
static const QMap< int, QString >& getFieldNames();
/// helper method that returns the field type as a string
static const QString getFieldName(const FieldType);
/// static method that returns the DataType enum as a QString
static const QMap< int, QString >& getDataNames();
static const QMap< int, QString >& getDataTypeNames();
/// Helper method that returns the datatype as a string
static const QString getDataTypeName(const DataType);
/// Returns the data type of a data array depending on the number of components of the given data array:
static const MeshDataModel::DataType getDataType(vtkSmartPointer<vtkDataArray>);
/** Returns the data type string of an data array depending on the number of components of the given data array:
* If the number of components is different than 1, 3 and 9 (the managed type SCALARS, VECTORS, TENSORS)
* then the method returns a string equals to the number of components.
*/
static const QString getDataTypeName(vtkSmartPointer<vtkDataArray>);
/// Helper method that returns the DisplayTypeFor3DData as a QString
static const QString getDisplayTypeFor3DDataName(const DisplayTypeFor3DData);
/**
* @brief Refresh the model
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment