Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
MeshComponent.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
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 MESHCOMPONENT_H
27#define MESHCOMPONENT_H
28
29#include "Component.h"
30#include "MeshSelectionModel.h"
31
32#include <QTableView>
33
34class vtkPointSet;
35class vtkSelection;
36class vtkSelectionNode;
37
38class QTableView;
39class QComboBox;
40
41namespace camitk {
42
43class MeshDataModel;
44class MeshDataView;
45class MeshSelectionView;
46
54 Q_OBJECT
55public:
56
58 enum DataType {
59 SCALARS = 1,
60 VECTORS = 2,
61 TENSORS = 4,
62 OTHERS = 8
63 };
64
66 enum FieldType {
67 POINTS = 1,
68 CELLS = 2,
69 MESH = 4
70 };
71
81
86 UNSCALED_ARROW
87 };
88
95 MeshComponent(const QString& file, const QString& name = "Mesh");
96
106 MeshComponent(vtkSmartPointer<vtkPointSet> aPointSet, const QString& name);
107
116 MeshComponent(Component* parentComponent, vtkSmartPointer<vtkPointSet> aPointSet, const QString& name);
117
119 ~MeshComponent() override;
120
122 void setName(const QString&) override;
123
125 void pointPicked(vtkIdType pointId, bool) override;
126
128 void cellPicked(vtkIdType cellId, bool) override;
129
131 vtkIdType getPickedPointId();
132
134 vtkIdType getPickedCellId();
135
137 unsigned int getNumberOfPropertyWidget() override;
138
140 QWidget* getPropertyWidgetAt(unsigned int i = 0) override;
141
143 QPixmap getIcon() override;
144
171
177 unsigned int getNumberOfSelections() const;
178
184 vtkSmartPointer<vtkSelection> getActiveSelection() const;
185
194 vtkSmartPointer<vtkSelectionNode> getSelection(const QString& name) const;
195
204 vtkSmartPointer<vtkSelectionNode> getSelectionAt(unsigned int index) const;
205
212 int getSelectionIndex(const QString& name) const;
213
227 virtual int addSelection(const QString& name, int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, MeshSelectionModel::InsertionPolicy policy = MeshSelectionModel::REPLACE);
228
240 virtual int addToSelectedSelection(int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, MeshSelectionModel::InsertionPolicy policy = MeshSelectionModel::REPLACE);
241
260 int getNumberOfDataArray(int fieldFlag = POINTS | CELLS);
261
270 vtkSmartPointer<vtkDataArray> getDataArray(FieldType fieldType, const QString& arrayName);
271
280 vtkSmartPointer<vtkDataArray> getDataArray(FieldType fieldType, int index);
281
289 void addDataArray(FieldType fieldType, const QString& name, vtkSmartPointer<vtkDataArray> data);
290
297 void removeDataArray(FieldType fieldType, const QString& name);
298
305 void addPointData(const QString& name, vtkSmartPointer<vtkDataArray> data);
306
313 void addCellData(const QString& name, vtkSmartPointer<vtkDataArray> data);
314
316 MeshDataModel* getDataModel();
317
319 vtkSmartPointer<vtkFieldData> getFieldData(FieldType);
320
322 bool getDataRepresentationVisibility(FieldType, const QString&) ;
323
326 void setDataRepresentationVisibility(FieldType fieldType, const QString& name, bool visibility, bool blockRefresh = false);
327
330 void setDataRepresentationOff(int dataType = SCALARS | VECTORS | TENSORS, bool blockRefresh = false);
331
337 static const QMap< int, QString >& getFieldNames();
338
340 static const QString getFieldName(const FieldType);
341
343 static const QMap< int, QString >& getDataTypeNames();
344
346 static const QString getDataTypeName(const DataType);
347
349 static const DataType getDataType(vtkSmartPointer<vtkDataArray>);
350
355 static const QString getDataTypeName(vtkSmartPointer<vtkDataArray>);
356
358 static const QString getSpecificRepresentationName(const SpecificRepresentation);
359
371 virtual QVariant toVariant() const override;
372
374 virtual void fromVariant(const QVariant&) override;
376
377
378protected:
379
381 void initRepresentation(vtkSmartPointer<vtkPointSet>);
382
384 void initSelection();
385
387 void initData();
388
390 void initDynamicProperties();
391
392protected slots:
393
395 void changeSelectedSelection(const QItemSelection& selected, const QItemSelection& deselected);
396
398 void removeSelectedSelections();
399
401 void removeSelectedData();
402
404 void displayTypePolicyChanged(int);
405
407 void vectorRepresentationPolicyChanged(int);
408
409private:
410
412 void initRepresentation() override final {}
413
415 bool isInInitRepresentation;
416
418 void init();
419
421 FrameOfReference* initialFrameOfReference;
422
424 vtkIdType pickedPointId;
425
427 vtkIdType pickedCellId;
428
430 vtkSmartPointer<vtkSelection> currentSelection;
431
434
436 MeshSelectionModel* selectionModel;
437
439 MeshSelectionView* selectionView;
440
442 QWidget* selectionWidget;
443
445 QAction* removeSelections;
446
448 QAction* mergeSelection;
449
451 QAction* inspectSelection;
452
454 QComboBox* insertionPolicyBox;
455
457 MeshDataModel* dataModel;
458
460 MeshDataView* dataView;
461
463 QWidget* dataWidget;
464
466 QComboBox* displayTypePolicyBox;
467
469 QComboBox* vectorRepresentationPolicyBox;
470
474 QMap<QString, vtkSmartPointer<vtkDataArray> > specific3DDataRepresentation;
475
477 unsigned int numberOfCellDataSpecificRepresentation;
478
480 QMap<vtkSmartPointer<vtkDataArray>, bool> dataRepresentationVisibility;
481
483 QStringList vectorActors;
484
486 void createDataRepresentation(FieldType, const QString&, SpecificRepresentation representation = VECTOR_3D) ;
487
488 // Returns the very specific name used for the additional prop that represent this data
489 const QString getDataPropName(FieldType, const QString&);
490
492 void setScalarDataRepresentationOn(vtkSmartPointer<vtkDataArray>);
493
495 static QMap< int, QString > initFieldNames();
496
498 static QMap< int, QString > initDataNames();
499
501 QAction* removeData;
502
504 QAction* inspectData;
505
506};
507
508}
509
510#endif // MESHCOMPONENT_H
#define CAMITK_API
Definition CamiTKAPI.h:66
Definition PersistenceManager.h:30
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition sdk/libraries/core/component/Component.h:304
Basic component to manage any kind of mesh.
Definition MeshComponent.h:53
SpecificRepresentation
3D data can be represented by 1 value in different ways
Definition MeshComponent.h:73
@ SECOND_COMPONENT
Use only the value of the second component.
Definition MeshComponent.h:77
@ VECTOR_3D
3D data are represented with 3D arrows or hedge hog (simple lines starting from the point or center o...
Definition MeshComponent.h:74
@ FIRST_COMPONENT
Use only the value of the first component.
Definition MeshComponent.h:76
@ NORM
3D data are represented in 1D using the norm of the three components
Definition MeshComponent.h:75
@ THIRD_COMPONENT
Use only the value of the third component.
Definition MeshComponent.h:78
FieldType
Data fields can be applied to one of this.
Definition MeshComponent.h:66
DataType
Data fields can have different dimensions.
Definition MeshComponent.h:58
VectorRepresentation
how are vector data represented in 3D
Definition MeshComponent.h:83
@ HEDGE_HOG
3D data are represented with hedge hog (simple lines starting from the point or center of the cell)
Definition MeshComponent.h:84
@ ARROW
3D data are represented with 3D arrows (nicer hedge hog)
Definition MeshComponent.h:85
Qt model for mesh data.
Definition MeshDataModel.h:45
InsertionPolicy
Definition MeshSelectionModel.h:50
Definition Action.cpp:40