ctkTransferFunctionItem.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 __ctkTransferFunctionItem_h
  15. #define __ctkTransferFunctionItem_h
  16. /// Qt includes
  17. #include <QGraphicsObject>
  18. /// CTK includes
  19. #include "ctkWidgetsExport.h"
  20. #include "ctkPimpl.h"
  21. #include "ctkTransferFunction.h"
  22. struct ctkControlPoint;
  23. class ctkTransferFunctionItemPrivate;
  24. /// \ingroup Widgets
  25. ///
  26. /// TODO: should probably derive from QGraphicsItem or QAbstractGraphicsShapeItem
  27. class CTK_WIDGETS_EXPORT ctkTransferFunctionItem: public QGraphicsObject
  28. {
  29. Q_OBJECT
  30. public:
  31. ctkTransferFunctionItem(QGraphicsItem* parent = 0);
  32. ctkTransferFunctionItem(ctkTransferFunction* transferFunction,
  33. QGraphicsItem* parent = 0);
  34. virtual ~ctkTransferFunctionItem();
  35. void setTransferFunction(ctkTransferFunction* transferFunction);
  36. ctkTransferFunction* transferFunction()const;
  37. inline void setRect(qreal x, qreal y, qreal width, qreal height);
  38. void setRect(const QRectF& rectangle);
  39. QRectF rect()const;
  40. /*
  41. qreal rangeXDiff();
  42. qreal rangeXOffSet();
  43. qreal rangeYDiff();
  44. qreal rangeYOffSet();
  45. QPointF transferFunction2ScreenCoordinates( qreal x, qreal y);
  46. QPointF screen2TransferFunctionCoordinates( qreal x, qreal y);
  47. */
  48. virtual QRectF boundingRect()const;
  49. protected:
  50. //qreal y(const QVariant& value)const;
  51. //inline qreal y(const ctkPoint& point)const;
  52. QColor color(const QVariant& value)const;
  53. inline QColor color(const ctkPoint& point)const;
  54. //QList<ctkPoint> bezierParams(ctkControlPoint* start, ctkControlPoint* end)const;
  55. //QList<ctkPoint> nonLinearPoints(ctkControlPoint* start, ctkControlPoint* end)const;
  56. virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value);
  57. protected:
  58. QScopedPointer<ctkTransferFunctionItemPrivate> d_ptr;
  59. private:
  60. Q_DECLARE_PRIVATE(ctkTransferFunctionItem);
  61. Q_DISABLE_COPY(ctkTransferFunctionItem);
  62. };
  63. //-----------------------------------------------------------------------------
  64. void ctkTransferFunctionItem::setRect(qreal x, qreal y, qreal width, qreal height)
  65. {
  66. this->setRect(QRectF(x,y,width,height));
  67. }
  68. /*
  69. //-----------------------------------------------------------------------------
  70. qreal ctkTransferFunctionItem::y(const ctkPoint& p)const
  71. {
  72. return this->y(p.Value);
  73. }
  74. //-----------------------------------------------------------------------------
  75. QColor ctkTransferFunctionItem::color(const ctkPoint& p)const
  76. {
  77. return this->color(p.Value);
  78. }
  79. */
  80. #endif