Computer Assited Medical Intervention Tool Kit  version 4.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-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 MESHCOMPONENT_H
27 #define MESHCOMPONENT_H
28 
29 #include "Component.h"
30 #include "Geometry.h"
31 #include "MeshDataModel.h"
32 #include "MeshDataView.h"
33 #include "MeshSelectionModel.h"
34 #include "MeshSelectionView.h"
35 
36 class vtkPointSet;
37 class vtkSelection;
38 class vtkSelectionNode;
39 
40 class QTableView;
41 class QComboBox;
42 
43 namespace camitk {
44 
52  Q_OBJECT
53 public:
54 
60  MeshComponent ( const QString & file ) throw ( AbortException );
61 
71  MeshComponent ( vtkSmartPointer<vtkPointSet> aPointSet, const QString &name );
72 
81  MeshComponent ( Component *parentComponent, vtkSmartPointer<vtkPointSet> aPointSet, const QString &name );
82 
84  virtual ~MeshComponent();
85 
87  void pointPicked ( vtkIdType pointId, bool );
88 
90  void cellPicked ( vtkIdType cellId, bool );
91 
93  vtkIdType getPickedPointId();
94 
96  vtkIdType getPickedCellId();
97 
99  void updateProperty ( QString , QVariant ) {}
100 
102  virtual unsigned int getNumberOfPropertyWidget();
103 
105  virtual QWidget * getPropertyWidgetAt ( unsigned int i, QWidget* parent = 0 );
106 
108  virtual QPixmap getIcon();
109 
135  QList< vtkSmartPointer<vtkSelectionNode> >& getSelections();
136 
142  unsigned int getNumberOfSelections() const;
143 
149  vtkSmartPointer<vtkSelection> getActiveSelection() const;
150 
159  vtkSmartPointer<vtkSelectionNode> getSelection ( const QString& name ) const;
160 
169  vtkSmartPointer<vtkSelectionNode> getSelectionAt ( unsigned int index ) const;
170 
177  int getSelectionIndex ( const QString& name ) const;
178 
192  virtual int addSelection ( const QString& name, int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, MeshSelectionModel::InsertionPolicy policy = MeshSelectionModel::REPLACE );
193 
205  virtual int addToSelectedSelection ( int fieldType, int contentType, vtkSmartPointer< vtkAbstractArray > array, MeshSelectionModel::InsertionPolicy policy = MeshSelectionModel::REPLACE );
206 
211 
214  const QMap< QString, vtkSmartPointer<vtkSelectionNode> >& getSelectionList() const;
216 
217 
235  vtkSmartPointer<vtkDataArray> getDataArray(MeshDataModel::FieldType fieldType, const QString& arrayName);
236 
245  vtkSmartPointer<vtkDataArray> getDataArray(MeshDataModel::FieldType fieldType, int index);
246 
254  void addDataArray ( MeshDataModel::FieldType fieldType, const QString& name, vtkSmartPointer<vtkDataArray> data );
255 
256 
263  void removeDataArray ( MeshDataModel::FieldType fieldType, const QString& name );
264 
271  void addPointData ( const QString& name, vtkSmartPointer<vtkDataArray> data );
272 
279  void addCellData ( const QString& name, vtkSmartPointer<vtkDataArray> data );
280 
289  vtkSmartPointer<vtkProp> getDataProp ( MeshDataModel::FieldType fieldType, const QString& name );
290 
302  void setActiveData(MeshDataModel::FieldType fieldType, const char *name);
303 
306  return dataModel;
307  }
312 protected:
313 
315  virtual void initRepresentation ( vtkSmartPointer<vtkPointSet> );
316 
318  virtual void initSelection();
319 
321  virtual void initData();
322 
324  virtual void initDynamicProperties();
325 
326 protected slots:
327 
329  void changeSelectedSelection ( const QItemSelection &selected, const QItemSelection &deselected );
330 
332  void removeSelectedSelections();
333 
335  void removeSelectedData();
336 
337 private:
338 
340  virtual void initRepresentation() {}
341 
343  void init();
344 
346  vtkIdType pickedPointId;
347 
349  vtkIdType pickedCellId;
350 
352  vtkSmartPointer<vtkSelection> currentSelection;
353 
355  QList< vtkSmartPointer<vtkSelectionNode> > selectionList;
356 
362  QMap< QString, vtkSmartPointer<vtkSelectionNode> > selectionMap;
364 
367 
370 
372  QWidget* selectionWidget;
373 
376 
378  QAction* mergeSelection;
379 
382 
384  QComboBox* policyBox;
385 
388 
391 
393  QWidget* dataWidget;
394 
396  QAction* removeData;
397 
399  QAction* inspectData;
400 
401 };
402 
403 }
404 
405 #endif // MESHCOMPONENT_H
QAction * inspectData
action to inspect data
Definition: MeshComponent.h:399
QWidget * dataWidget
selection widget
Definition: MeshComponent.h:393
Exception class to handle abortion in component instanciation.
Definition: AbortException.h:43
QComboBox * policyBox
combo box to select the selection insertion policy
Definition: MeshComponent.h:384
Qt model for mesh selection This class use the Qt model/view design.
Definition: MeshSelectionModel.h:44
Qt model for mesh data.
Definition: MeshDataModel.h:40
QWidget * selectionWidget
selection widget
Definition: MeshComponent.h:372
QAction * mergeSelection
action to merge selections
Definition: MeshComponent.h:378
QAction * inspectSelection
action to inspect selection
Definition: MeshComponent.h:381
Qt view for mesh selection This class use the Qt model/view design.
Definition: MeshSelectionView.h:40
Qt view for mesh selection This class use the Qt model/view design.
Definition: MeshDataView.h:40
Definition: Action.cpp:40
Basic component to manage any kind of mesh.
Definition: MeshComponent.h:51
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:299
#define CAMITK_API
Definition: CamiTKAPI.h:49
virtual void initRepresentation()
the concrete building of the 3D objects (Slice/Geometry): none in this case, everything is done by in...
Definition: MeshComponent.h:340
Definition: MeshSelectionModel.h:51
MeshDataModel * dataModel
data model (model as the M in Qt MVC design pattern)
Definition: MeshComponent.h:387
void updateProperty(QString, QVariant)
update property: no specific properties to manage, this is needed to avoid console warnings...
Definition: MeshComponent.h:99
QList< vtkSmartPointer< vtkSelectionNode > > selectionList
list of selections
Definition: MeshComponent.h:355
MeshSelectionModel * selectionModel
selection model (model as the M in Qt MVC design pattern)
Definition: MeshComponent.h:366
vtkIdType pickedPointId
the last picked point
Definition: MeshComponent.h:346
InsertionPolicy
Definition: MeshSelectionModel.h:50
vtkSmartPointer< vtkSelection > currentSelection
manages current selection using vtk
Definition: MeshComponent.h:352
QAction * removeData
action to remove data
Definition: MeshComponent.h:396
vtkIdType pickedCellId
the last picked cell
Definition: MeshComponent.h:349
FieldType
Data fields can be applied to one of this.
Definition: MeshDataModel.h:47
MeshDataView * dataView
data GUI View (view as the V in Qt MVC design pattern)
Definition: MeshComponent.h:390
MeshSelectionView * selectionView
selection GUI View (view as the V in Qt MVC design pattern)
Definition: MeshComponent.h:369
QAction * removeSelections
action to remove selections
Definition: MeshComponent.h:375
MeshDataModel * getDataModel()
get the current data view model (model as the M in Qt MVC design pattern)
Definition: MeshComponent.h:305