Computer Assited Medical Intervention Tool Kit  version 5.0
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-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, 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 
34 class vtkPointSet;
35 class vtkSelection;
36 class vtkSelectionNode;
37 
38 class QTableView;
39 class QComboBox;
40 
41 namespace camitk {
42 
43 class MeshDataModel;
44 class MeshDataView;
45 class MeshSelectionView;
46 
54  Q_OBJECT
55 public:
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 
75  NORM,
78  THIRD_COMPONENT
79  //@TODO COLOR, ///< 3D data are represented as a specific color @TODO need to build a specific color map LUT containing as many colors as there is point/cell
80  };
81 
86  UNSCALED_ARROW
87  };
88 
95  MeshComponent(const QString& file);
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 pointPicked(vtkIdType pointId, bool) override;
123 
125  void cellPicked(vtkIdType cellId, bool) override;
126 
128  vtkIdType getPickedPointId();
129 
131  vtkIdType getPickedCellId();
132 
134  void updateProperty(QString, QVariant) override {}
135 
137  unsigned int getNumberOfPropertyWidget() override;
138 
140  QWidget* getPropertyWidgetAt(unsigned int i = 0) override;
141 
143  QPixmap getIcon() override;
144 
170  QList< vtkSmartPointer<vtkSelectionNode> >& getSelections();
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 
325  void setDataRepresentationVisibility(FieldType, const QString&, bool);
326 
328  void setDataRepresentationOff(int dataType = SCALARS | VECTORS | TENSORS);
329 
331  void setVectorRepresentation(VectorRepresentation);
332 
337  static const QMap< int, QString >& getFieldNames();
339 
341  static const QString getFieldName(const FieldType);
342 
344  static const QMap< int, QString >& getDataTypeNames();
345 
347  static const QString getDataTypeName(const DataType);
348 
350  static const DataType getDataType(vtkSmartPointer<vtkDataArray>);
351 
356  static const QString getDataTypeName(vtkSmartPointer<vtkDataArray>);
357 
359  static const QString getSpecificRepresentationName(const SpecificRepresentation);
360 
365 protected:
366 
368  void initRepresentation(vtkSmartPointer<vtkPointSet>);
369 
371  void initSelection();
372 
374  void initData();
375 
377  void initDynamicProperties();
378 
379 protected slots:
380 
382  void changeSelectedSelection(const QItemSelection& selected, const QItemSelection& deselected);
383 
385  void removeSelectedSelections();
386 
388  void removeSelectedData();
389 
391  void displayTypePolicyChanged(int);
392 
394  void vectorRepresentationPolicyChanged(int);
395 
396 private:
397 
399  void initRepresentation() override final {}
400 
402  void init();
403 
405  vtkIdType pickedPointId;
406 
408  vtkIdType pickedCellId;
409 
411  vtkSmartPointer<vtkSelection> currentSelection;
412 
414  QList< vtkSmartPointer<vtkSelectionNode> > selectionList;
415 
418 
421 
423  QWidget* selectionWidget;
424 
427 
429  QAction* mergeSelection;
430 
433 
435  QComboBox* insertionPolicyBox;
436 
439 
442 
444  QWidget* dataWidget;
445 
448 
451 
455  QMap<QString, vtkSmartPointer<vtkDataArray> > specific3DDataRepresentation;
456 
459 
461  QMap<vtkSmartPointer<vtkDataArray>, bool> dataRepresentationVisibility;
462 
464  QStringList vectorActors;
465 
467  void createDataRepresentation(FieldType, const QString&, SpecificRepresentation representation = VECTOR_3D) ;
468 
469  // Returns the very specific name used for the additional prop that represent this data
470  const QString getDataPropName(FieldType, const QString&);
471 
473  void setScalarDataRepresentationOn(vtkSmartPointer<vtkDataArray>);
474 
476  static QMap< int, QString > initFieldNames();
477 
479  static QMap< int, QString > initDataNames();
480 
482  QAction* removeData;
483 
485  QAction* inspectData;
486 
487 };
488 
489 }
490 
491 #endif // MESHCOMPONENT_H
camitk::MeshComponent::SpecificRepresentation
SpecificRepresentation
Definition: MeshComponent.h:73
CAMITK_WARNING
#define CAMITK_WARNING(MSG)
Log for warning verbosity (the most common one) Will appear by default.
Definition: Log.h:266
camitk::MeshComponent::dataWidget
QWidget * dataWidget
selection widget
Definition: MeshComponent.h:444
camitk::MeshComponent::FIRST_COMPONENT
@ FIRST_COMPONENT
Use only the value of the first component.
Definition: MeshComponent.h:76
camitk::MeshDataModel
Qt model for mesh data. This class use the Qt model/view design.
Definition: MeshDataModel.h:68
camitk::MeshComponent::removeData
QAction * removeData
action to remove data
Definition: MeshComponent.h:482
MeshDataModel.h
camitk::MeshComponent::specific3DDataRepresentation
QMap< QString, vtkSmartPointer< vtkDataArray > > specific3DDataRepresentation
map of specific 3D Data representations.
Definition: MeshComponent.h:455
camitk::InteractiveViewer::setColorScaleTitle
void setColorScaleTitle(QString t)
set the color scale title.
Definition: InteractiveViewer.cpp:1769
camitk::MeshSelectionModel::InsertionPolicy
InsertionPolicy
Definition: MeshSelectionModel.h:50
camitk::MeshComponent::pickedPointId
vtkIdType pickedPointId
the last picked point
Definition: MeshComponent.h:405
camitk::MeshComponent::updateProperty
void updateProperty(QString, QVariant) override
update property: no specific properties to manage, this is needed to avoid console warnings.
Definition: MeshComponent.h:134
camitk::Component::setIndexOfPropertyExplorerTab
void setIndexOfPropertyExplorerTab(unsigned int index) override final
Set the index of the tab in the ProperlyExplorer to select for display.
Definition: sdk/libraries/core/component/Component.h:492
Geometry.h
camitk::MeshComponent::SECOND_COMPONENT
@ SECOND_COMPONENT
Use only the value of the second component.
Definition: MeshComponent.h:77
camitk::MeshSelectionView
Qt view for mesh selection.
Definition: MeshSelectionView.h:63
camitk::MeshComponent::displayTypePolicyBox
QComboBox * displayTypePolicyBox
combo box to select how to display vector data (data with 3 components)
Definition: MeshComponent.h:447
camitk::MeshComponent::pickedCellId
vtkIdType pickedCellId
the last picked cell
Definition: MeshComponent.h:408
camitk::InteractiveViewer
InteractiveViewer is used to view 3D objects and slices (anything that provides either a InterfaceBit...
Definition: InteractiveViewer.h:112
camitk::MeshSelectionModel::REPLACE
@ REPLACE
Definition: MeshSelectionModel.h:51
camitk::Property
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:303
Log.h
camitk::MeshComponent::DataType
DataType
Definition: MeshComponent.h:58
camitk::MeshComponent::dataModel
MeshDataModel * dataModel
data model (model as the M in Qt MVC design pattern)
Definition: MeshComponent.h:438
MeshComponent.h
camitk::MeshComponent::removeSelections
QAction * removeSelections
action to remove selections
Definition: MeshComponent.h:426
Property.h
camitk::MeshComponent::mergeSelection
QAction * mergeSelection
action to merge selections
Definition: MeshComponent.h:429
camitk::MeshComponent::MeshComponent
MeshComponent(const QString &file)
Creates a top-level MeshComponent from a file.
Definition: MeshComponent.cpp:97
camitk::MeshComponent::selectionModel
MeshSelectionModel * selectionModel
selection model (model as the M in Qt MVC design pattern)
Definition: MeshComponent.h:417
camitk::MeshComponent::NORM
@ NORM
3D data are represented in 1D using the norm of the three components
Definition: MeshComponent.h:75
camitk::MeshComponent::ARROW
@ ARROW
3D data are represented with 3D arrows (nicer hedge hog)
Definition: MeshComponent.h:85
camitk::policy
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding)
MeshSelectionModel.h
camitk::addProp
addProp(axes)
camitk::InteractiveViewer::setColorScale
void setColorScale(bool)
Definition: InteractiveViewer.cpp:1759
camitk::MeshComponent::dataRepresentationVisibility
QMap< vtkSmartPointer< vtkDataArray >, bool > dataRepresentationVisibility
map of visibility status of data
Definition: MeshComponent.h:461
camitk::MeshComponent::inspectSelection
QAction * inspectSelection
action to inspect selection
Definition: MeshComponent.h:432
camitk::MeshComponent::numberOfCellDataSpecificRepresentation
unsigned int numberOfCellDataSpecificRepresentation
number of specific 3D representation for cell data
Definition: MeshComponent.h:458
Component
A component is something that composed something and could also be a part of something.
Definition: modeling/libraries/pml/Component.h:48
camitk::MeshComponent::HEDGE_HOG
@ HEDGE_HOG
3D data are represented with hedge hog (simple lines starting from the point or center of the cell)
Definition: MeshComponent.h:84
camitk::MeshComponent::currentSelection
vtkSmartPointer< vtkSelection > currentSelection
manages current selection using vtk
Definition: MeshComponent.h:411
camitk::MeshComponent::selectionWidget
QWidget * selectionWidget
selection widget
Definition: MeshComponent.h:423
camitk::MeshDataView
Qt view for mesh data.
Definition: MeshDataView.h:63
camitk::removeProp
void removeProp(vtkSmartPointer< vtkProp > p, bool refresh=false)
remove the given vtkProp (e.g.
camitk::MeshComponent::selectionList
QList< vtkSmartPointer< vtkSelectionNode > > selectionList
list of selections
Definition: MeshComponent.h:414
InteractiveViewer.h
MeshSelectionView.h
camitk::MeshComponent::vectorRepresentationPolicyBox
QComboBox * vectorRepresentationPolicyBox
combo box to select how the vector are represented in 3D
Definition: MeshComponent.h:450
camitk::MeshSelectionModel
Qt model for mesh selection This class use the Qt model/view design.
Definition: MeshSelectionModel.h:44
camitk::Property::setReadOnly
void setReadOnly(bool)
set this property as read-only
Definition: Property.cpp:82
camitk::MeshComponent::vectorActors
QStringList vectorActors
list of all vector data 3D actors' names (needed for cleaning up)
Definition: MeshComponent.h:464
camitk::MeshComponent::VECTOR_3D
@ 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
camitk::MeshComponent
Basic component to manage any kind of mesh.
Definition: MeshComponent.h:53
camitk::refresh
void refresh()
refresh the display
camitk::MeshComponent::selectionView
MeshSelectionView * selectionView
selection GUI View (view as the V in Qt MVC design pattern)
Definition: MeshComponent.h:420
camitk::MeshComponent::dataView
MeshDataView * dataView
data GUI View (view as the V in Qt MVC design pattern)
Definition: MeshComponent.h:441
camitk::MeshComponent::inspectData
QAction * inspectData
action to inspect data
Definition: MeshComponent.h:485
camitk::MeshComponent::FieldType
FieldType
Definition: MeshComponent.h:66
MeshDataView.h
camitk::MeshComponent::initRepresentation
void initRepresentation() override final
the concrete building of the 3D objects (Slice/Geometry): none in this case, everything is done by in...
Definition: MeshComponent.h:399
camitk::MeshComponent::VectorRepresentation
VectorRepresentation
Definition: MeshComponent.h:83
camitk::MeshComponent::insertionPolicyBox
QComboBox * insertionPolicyBox
combo box to select the selection insertion policy
Definition: MeshComponent.h:435
camitk::Component
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:302
Application.h
CAMITK_API
#define CAMITK_API
Definition: CamiTKAPI.h:49
camitk
Definition: Action.cpp:35