ctkVTKDataSetArrayComboBox.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkVTKDataSetArrayComboBox_h
  15. #define __ctkVTKDataSetArrayComboBox_h
  16. // Qt includes
  17. #include <QComboBox>
  18. // CTK includes
  19. #include "ctkVisualizationVTKWidgetsExport.h"
  20. #include "ctkVTKDataSetModel.h"
  21. class ctkVTKDataSetArrayComboBoxPrivate;
  22. class vtkAbstractArray;
  23. class vtkDataSet;
  24. /// \ingroup Visualization_VTK_Widgets
  25. ///
  26. /// QComboBox linked to vtkDataSet field arrays
  27. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKDataSetArrayComboBox
  28. : public QComboBox
  29. {
  30. Q_OBJECT
  31. Q_PROPERTY(ctkVTKDataSetModel::AttributeTypes attributeTypes READ attributeTypes WRITE setAttributeTypes)
  32. public:
  33. /// Superclass typedef
  34. typedef QComboBox Superclass;
  35. /// Constructors
  36. explicit ctkVTKDataSetArrayComboBox(QWidget* parent = 0);
  37. virtual ~ctkVTKDataSetArrayComboBox();
  38. vtkAbstractArray* currentArray()const;
  39. QString currentArrayName()const;
  40. vtkDataSet* dataSet()const;
  41. /// Return the current array location, i.e. whether it's a point data
  42. /// array or a cell data array.
  43. /// \sa currentArrayChanged(int), ctkVTKDataSetModel::locationFromItem()
  44. int currentArrayLocation()const;
  45. ctkVTKDataSetModel::AttributeTypes attributeTypes()const;
  46. void setAttributeTypes(const ctkVTKDataSetModel::AttributeTypes& attributeTypes);
  47. /// Return a pointer to the model used to populate the combobox.
  48. /// \sa dataSet()
  49. ctkVTKDataSetModel* dataSetModel()const;
  50. public Q_SLOTS:
  51. /// Set the dataset to observe. It is used to as the "model" for the combobox.
  52. /// \sa dataSet(), dataSetModel()
  53. void setDataSet(vtkDataSet* dataSet);
  54. /// The array must exist in the dataset
  55. void setCurrentArray(vtkAbstractArray* dataArray);
  56. /// the array must exist in the dataset
  57. void setCurrentArray(const QString& name);
  58. Q_SIGNALS:
  59. void currentArrayChanged(vtkAbstractArray*);
  60. void currentArrayChanged(const QString& name);
  61. protected Q_SLOTS:
  62. void onCurrentIndexChanged(int);
  63. protected:
  64. QScopedPointer<ctkVTKDataSetArrayComboBoxPrivate> d_ptr;
  65. private:
  66. Q_DECLARE_PRIVATE(ctkVTKDataSetArrayComboBox);
  67. Q_DISABLE_COPY(ctkVTKDataSetArrayComboBox);
  68. };
  69. #endif