ctkVTKHistogram.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 __ctkVTKHistogram_h
  15. #define __ctkVTKHistogram_h
  16. // CTK includes
  17. #include "ctkHistogram.h"
  18. #include "ctkPimpl.h"
  19. #include "ctkVisualizationVTKWidgetsExport.h"
  20. #include "ctkVTKObject.h"
  21. class vtkDataArray;
  22. class ctkVTKHistogramPrivate;
  23. /// \ingroup Visualization_VTK_Widgets
  24. ///
  25. /// Transfer function for a vtkColorTransferFunction.
  26. /// The value is an RGB QColor (no alpha supported)
  27. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKHistogram: public ctkHistogram
  28. {
  29. Q_OBJECT;
  30. QVTK_OBJECT;
  31. Q_PROPERTY(int component READ component WRITE setComponent)
  32. Q_PROPERTY(QVariant maxValue READ maxValue)
  33. Q_PROPERTY(QVariant minValue READ minValue)
  34. Q_PROPERTY(int numberOfBins READ numberOfBins WRITE setNumberOfBins)
  35. public:
  36. ctkVTKHistogram(QObject* parent = 0);
  37. ctkVTKHistogram(vtkDataArray* dataArray, QObject* parent = 0);
  38. virtual ~ctkVTKHistogram();
  39. virtual ctkControlPoint* controlPoint(int index)const;
  40. virtual QVariant value(qreal pos)const;
  41. /// Returns the number of bins. Returns 0 until build() is called.
  42. virtual int count()const;
  43. // Set/Get the range of the histogram.
  44. // Please note that after an array is set, the range will be reset.
  45. // \sa resetRange()
  46. virtual void setRange(qreal minRang, qreal maxRange);
  47. virtual void range(qreal& minRange, qreal& maxRange)const;
  48. // Reset the range to the array's range.
  49. virtual void resetRange();
  50. virtual QVariant minValue()const;
  51. virtual QVariant maxValue()const;
  52. Q_INVOKABLE void setDataArray(vtkDataArray* dataArray);
  53. Q_INVOKABLE vtkDataArray* dataArray()const;
  54. void setComponent(int component);
  55. int component()const;
  56. // Set the number of bins to use in the histogram. If this is set,
  57. // the range will be ignored.
  58. int numberOfBins()const;
  59. void setNumberOfBins(int number);
  60. Q_INVOKABLE virtual void removeControlPoint( qreal pos );
  61. Q_INVOKABLE virtual void build();
  62. protected:
  63. qreal indexToPos(int index)const;
  64. int posToIndex(qreal pos)const;
  65. protected:
  66. QScopedPointer<ctkVTKHistogramPrivate> d_ptr;
  67. private:
  68. Q_DECLARE_PRIVATE(ctkVTKHistogram);
  69. Q_DISABLE_COPY(ctkVTKHistogram);
  70. };
  71. #endif