ctkVTKScalarsToColorsComboBox.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 __ctkVTKScalarsToColorsComboBox_h
  15. #define __ctkVTKScalarsToColorsComboBox_h
  16. // CTK includes
  17. #include "ctkComboBox.h"
  18. #include "ctkVisualizationVTKWidgetsExport.h"
  19. // VTK includes
  20. #include <vtkSmartPointer.h>
  21. class ctkVTKScalarsToColorsComboBoxPrivate;
  22. class vtkScalarsToColors;
  23. /// \ingroup Visualization_VTK_Widgets
  24. ///
  25. /// QComboBox linked to vtkScalarsToColors objects
  26. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKScalarsToColorsComboBox
  27. : public ctkComboBox
  28. {
  29. Q_OBJECT
  30. /// Superclass typedef
  31. typedef ctkComboBox Superclass;
  32. /// This property controls the current scalarsToColors item of the combobox.
  33. /// \accessors currentScalarsToColors(), setCurrentScalarsToColors()
  34. Q_PROPERTY(vtkScalarsToColors* currentScalarsToColors
  35. READ currentScalarsToColors WRITE setCurrentScalarsToColors
  36. NOTIFY currentScalarsToColorsChanged);
  37. public:
  38. /// Constructors
  39. explicit ctkVTKScalarsToColorsComboBox(QWidget* parent = 0);
  40. virtual ~ctkVTKScalarsToColorsComboBox();
  41. /// Add scalars to colors function (of any type) to the combobox.
  42. /// Increment reference count of given function (if any)
  43. /// Returns the index of the added function.
  44. int addScalarsToColors(vtkScalarsToColors* function, const QString& text =
  45. QString());
  46. vtkScalarsToColors* getScalarsToColors(int index) const;
  47. /// Searches the combobox for the given scalarsToColors
  48. /// \sa findText()
  49. int findScalarsToColors(vtkScalarsToColors* scalarsToColors) const;
  50. void removeScalarsToColors(vtkScalarsToColors* scalarsToColors);
  51. /// Returns the currentScalarsToColors property value
  52. /// 0 if no item is selected
  53. vtkScalarsToColors* currentScalarsToColors() const;
  54. public slots:
  55. ///
  56. void setCurrentScalarsToColors(vtkScalarsToColors* scalarsToColors);
  57. signals:
  58. /// Signal triggered when the current scalars to colors function changes.
  59. void currentScalarsToColorsChanged(vtkScalarsToColors*);
  60. protected slots:
  61. void onCurrentIndexChanged(int);
  62. void onRowsAboutToBeRemoved(const QModelIndex& parent, int first, int last);
  63. protected:
  64. QScopedPointer<ctkVTKScalarsToColorsComboBoxPrivate> d_ptr;
  65. private:
  66. Q_DECLARE_PRIVATE(ctkVTKScalarsToColorsComboBox);
  67. Q_DISABLE_COPY(ctkVTKScalarsToColorsComboBox);
  68. };
  69. #endif