ctkVisualizationVTKWidgetsPythonQtDecorators.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 __ctkVisualizationVTKWidgetsPythonQtDecorators_h
  15. #define __ctkVisualizationVTKWidgetsPythonQtDecorators_h
  16. // PythonQt includes
  17. #include <PythonQt.h>
  18. // CTK includes
  19. #include <ctkVTKChartView.h>
  20. #include <ctkVTKScalarsToColorsView.h>
  21. // NOTE:
  22. //
  23. // For decorators it is assumed that the methods will never be called
  24. // with the self argument as NULL. The self argument is the first argument
  25. // for non-static methods.
  26. //
  27. /// \ingroup Widgets
  28. class ctkVisualizationVTKWidgetsPythonQtDecorators : public QObject
  29. {
  30. Q_OBJECT
  31. public:
  32. ctkVisualizationVTKWidgetsPythonQtDecorators()
  33. {
  34. }
  35. public Q_SLOTS:
  36. // ctkVTKChartView
  37. #ifdef CTK_USE_CHARTS
  38. QList<double> chartExtent(ctkVTKChartView* view)const
  39. {
  40. double _bounds[8];
  41. view->chartExtent(_bounds);
  42. QList<double> bounds;
  43. for(int idx = 0; idx < 8; ++idx)
  44. {
  45. bounds << _bounds[idx];
  46. }
  47. return bounds;
  48. }
  49. QList<double> chartBounds(ctkVTKChartView* view)const
  50. {
  51. double _bounds[8];
  52. view->chartBounds(_bounds);
  53. QList<double> bounds;
  54. for(int idx = 0; idx < 8; ++idx)
  55. {
  56. bounds << _bounds[idx];
  57. }
  58. return bounds;
  59. }
  60. void setChartUserBounds(ctkVTKChartView* view, const QList<double>& bounds)
  61. {
  62. double _bounds[8];
  63. for(int idx = 0; idx < bounds.length() && idx < 8; ++idx)
  64. {
  65. _bounds[idx] = bounds[idx];
  66. }
  67. view->setChartUserBounds(_bounds);
  68. }
  69. QList<double> chartUserBounds(ctkVTKChartView* view)const
  70. {
  71. double _bounds[8];
  72. view->chartUserBounds(_bounds);
  73. QList<double> bounds;
  74. for(int idx = 0; idx < 8; ++idx)
  75. {
  76. bounds << _bounds[idx];
  77. }
  78. return bounds;
  79. }
  80. // ctkVTKScalarsToColorsView
  81. QList<double> validBounds(ctkVTKScalarsToColorsView* view)const
  82. {
  83. double _bounds[4];
  84. view->validBounds(_bounds);
  85. QList<double> bounds;
  86. for(int idx = 0; idx < 4; ++idx)
  87. {
  88. bounds << _bounds[idx];
  89. }
  90. return bounds;
  91. }
  92. void setValidBounds(ctkVTKScalarsToColorsView* view, const QList<double>& bounds)
  93. {
  94. double _bounds[4];
  95. for(int idx = 0; idx < bounds.length() && idx < 4; ++idx)
  96. {
  97. _bounds[idx] = bounds[idx];
  98. }
  99. view->setValidBounds(_bounds);
  100. }
  101. #endif
  102. };
  103. //-----------------------------------------------------------------------------
  104. /// \ingroup Widgets
  105. void initCTKVisualizationVTKWidgetsPythonQtDecorators()
  106. {
  107. PythonQt::self()->addDecorators(new ctkVisualizationVTKWidgetsPythonQtDecorators);
  108. }
  109. #endif