ctkVTKScalarsToColorsView.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 __ctkVTKScalarsToColorsView_h
  15. #define __ctkVTKScalarsToColorsView_h
  16. // CTK includes
  17. #include "ctkVTKChartView.h"
  18. #include "ctkVTKObject.h"
  19. class ctkVTKScalarsToColorsViewPrivate;
  20. // VTK includes
  21. #include <QVTKWidget.h>
  22. #include <vtkChartXY.h>
  23. class vtkColorTransferFunction;
  24. class vtkLookupTable;
  25. class vtkPiecewiseFunction;
  26. class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKScalarsToColorsView
  27. : public ctkVTKChartView
  28. {
  29. Q_OBJECT
  30. QVTK_OBJECT
  31. public:
  32. typedef ctkVTKChartView Superclass;
  33. ctkVTKScalarsToColorsView(QWidget* parent = 0);
  34. virtual ~ctkVTKScalarsToColorsView();
  35. virtual void addPlot(vtkPlot* plot);
  36. vtkPlot* addLookupTable(vtkLookupTable* lut);
  37. vtkPlot* addColorTransferFunction(vtkColorTransferFunction* colorTF, bool editable = true);
  38. vtkPlot* addOpacityFunction(vtkPiecewiseFunction* opacityTF, bool editable = true);
  39. vtkPlot* addCompositeFunction(vtkColorTransferFunction* colorTF,
  40. vtkPiecewiseFunction* opacityTF,
  41. bool colorTFEditable = true,
  42. bool opacityTFEditable = true);
  43. vtkPlot* addPiecewiseFunction(vtkPiecewiseFunction* piecewiseTF, bool editable = true);
  44. vtkPlot* addColorTransferFunctionControlPoints(vtkColorTransferFunction* colorTF);
  45. vtkPlot* addOpacityFunctionControlPoints(vtkPiecewiseFunction* opacityTF);
  46. vtkPlot* addCompositeFunctionControlPoints(vtkColorTransferFunction* colorTF,
  47. vtkPiecewiseFunction* opacityTF);
  48. vtkPlot* addPiecewiseFunctionControlPoints(vtkPiecewiseFunction* piecewiseTF);
  49. QList<vtkPlot*> plots()const;
  50. template<class T>
  51. QList<T*> plots()const;
  52. QList<vtkPlot*> lookupTablePlots()const;
  53. QList<vtkPlot*> lookupTablePlots(vtkLookupTable* lut)const;
  54. QList<vtkPlot*> colorTransferFunctionPlots()const;
  55. QList<vtkPlot*> colorTransferFunctionPlots(vtkColorTransferFunction* colorTF)const;
  56. QList<vtkPlot*> opacityFunctionPlots()const;
  57. QList<vtkPlot*> opacityFunctionPlots(vtkPiecewiseFunction* opacityTF)const;
  58. void setLookuptTableToPlots(vtkLookupTable* lut);
  59. void setColorTransferFunctionToPlots(vtkColorTransferFunction* colorTF);
  60. void setOpacityFunctionToPlots(vtkPiecewiseFunction* opacityTF);
  61. void setPiecewiseFunctionToPlots(vtkPiecewiseFunction* piecewiseTF);
  62. void setPlotsUserBounds(double* bounds);
  63. /// Reimplemented to set the bounds to the plots as well
  64. virtual void boundAxesToChartBounds();
  65. public slots:
  66. void editPoint(vtkObject* plot, void * pointId);
  67. protected slots:
  68. void onBoundsChanged();
  69. protected:
  70. QScopedPointer<ctkVTKScalarsToColorsViewPrivate> d_ptr;
  71. private:
  72. Q_DECLARE_PRIVATE(ctkVTKScalarsToColorsView);
  73. Q_DISABLE_COPY(ctkVTKScalarsToColorsView);
  74. };
  75. // ----------------------------------------------------------------------------
  76. template<class T>
  77. QList<T*> ctkVTKScalarsToColorsView::plots()const
  78. {
  79. QList<T*> res;
  80. const vtkIdType count = this->chart()->GetNumberOfPlots();
  81. for(vtkIdType i = 0; i < count; ++i)
  82. {
  83. vtkPlot* plot = this->chart()->GetPlot(i);
  84. if (T::SafeDownCast(plot) != 0)
  85. {
  86. res << T::SafeDownCast(plot);
  87. }
  88. }
  89. return res;
  90. }
  91. #endif