ctkTransferFunctionControlPointsItem.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 __ctkTransferFunctionControlPointsItem_h
  15. #define __ctkTransferFunctionControlPointsItem_h
  16. /// Qt includes
  17. #include <QGraphicsObject>
  18. /// CTK includes
  19. #include "ctkWidgetsExport.h"
  20. #include "ctkPimpl.h"
  21. #include "ctkTransferFunctionItem.h"
  22. class ctkTransferFunctionControlPointsItemPrivate;
  23. //-----------------------------------------------------------------------------
  24. class CTK_WIDGETS_EXPORT ctkTransferFunctionControlPointsItem: public ctkTransferFunctionItem
  25. {
  26. Q_OBJECT
  27. public:
  28. enum MOVE_TYPE{
  29. STOP_MOVE = 0,
  30. SWITCH_MOVE,
  31. DRAW_MOVE,
  32. FUSION_MOVE
  33. };
  34. explicit ctkTransferFunctionControlPointsItem(QGraphicsItem* parent = 0);
  35. ctkTransferFunctionControlPointsItem(ctkTransferFunction* transferFunction,
  36. QGraphicsItem* parent = 0);
  37. virtual ~ctkTransferFunctionControlPointsItem();
  38. virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
  39. protected:
  40. virtual void mousePressEvent(QGraphicsSceneMouseEvent* e);
  41. virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* e);
  42. virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* e);
  43. virtual void keyPressEvent (QKeyEvent * keyEvent);
  44. protected:
  45. QScopedPointer<ctkTransferFunctionControlPointsItemPrivate> d_ptr;
  46. private:
  47. Q_DECLARE_PRIVATE(ctkTransferFunctionControlPointsItem);
  48. Q_DISABLE_COPY(ctkTransferFunctionControlPointsItem);
  49. /*
  50. * \brief Update the position of a point when a move mouse event occurs
  51. */
  52. void updatePointPosition( QPointF iPoint );
  53. /*
  54. * \brief Stop "moving point" if its position reaches another point
  55. */
  56. void stopPoints( QPointF iPointF );
  57. /*
  58. * \brief Switch "moving point" and "reached point" when "moving point" reaches a point.
  59. * Position of "reached point" - IS NOT - lost.
  60. */
  61. void switchPoints( QPointF iPointF );
  62. /*
  63. * \brief Switch "moving point" and "reached point" when "moving point" reaches a point.
  64. * Position of "reached point" - IS - lost.
  65. */
  66. void drawPoints( QPointF iPointF );
  67. /*
  68. * \brief The moving (or reached point?) is deleted
  69. */
  70. void fusionPoints( QPointF iPointF );
  71. };
  72. #endif