ctkTransferFunctionControlPointsItem.h 2.9 KB

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