vtkCompositeControlPointsItem.h 4.66 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkCompositeControlPointsItem.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

16 17 18 19 20 21 22 23 24 25 26 27 28
/**
 * @class   vtkCompositeControlPointsItem
 * @brief   Control points for
 * vtkCompositeFunction.
 *
 * vtkCompositeControlPointsItem draws the control points of a vtkPiecewiseFunction
 * and a vtkColorTransferFunction.
 * @sa
 * vtkControlPointsItem
 * vtkColorTransferControlPointsItem
 * vtkCompositeTransferFunctionItem
 * vtkPiecewisePointHandleItem
*/
29

30 31
#ifndef vtkCompositeControlPointsItem_h
#define vtkCompositeControlPointsItem_h
32

33
#include "vtkChartsCoreModule.h" // For export macro
34 35 36
#include "vtkColorTransferControlPointsItem.h"

class vtkPiecewiseFunction;
37
class vtkPiecewisePointHandleItem;
38

39
class VTKCHARTSCORE_EXPORT vtkCompositeControlPointsItem:
40 41 42 43
  public vtkColorTransferControlPointsItem
{
public:
  vtkTypeMacro(vtkCompositeControlPointsItem, vtkColorTransferControlPointsItem);
44
  void PrintSelf(ostream &os, vtkIndent indent) override;
45

46 47 48
  /**
   * Creates a piecewise control points object
   */
49 50
  static vtkCompositeControlPointsItem* New();

51 52 53
  /**
   * Set the color transfer function to draw its points
   */
54 55
  virtual void SetColorTransferFunction(vtkColorTransferFunction* function);

56 57 58 59
  //@{
  /**
   * Utility function that calls SetPiecewiseFunction()
   */
60 61
  void SetOpacityFunction(vtkPiecewiseFunction* opacity);
  vtkGetObjectMacro(OpacityFunction, vtkPiecewiseFunction);
62
  //@}
63

64
  enum PointsFunctionType{
65 66 67 68
    ColorPointsFunction = 1,
    OpacityPointsFunction = 2,
    ColorAndOpacityPointsFunction = 3
  };
69 70
  //@{
  /**
71
   * PointsFunction controls whether the points represent the
72 73 74 75 76 77 78 79 80 81
   * ColorTransferFunction, OpacityTransferFunction or both.
   * If ColorPointsFunction, only the points of the ColorTransfer function are
   * used.
   * If OpacityPointsFunction, only the points of the Opacity function are used
   * If ColorAndOpacityPointsFunction, the points of both functions are shared
   * by both functions.
   * ColorAndOpacityPointsFunction by default.
   * Note: Set the mode before the functions are set. ColorPointsFunction is
   * not fully supported.
   */
82 83
  vtkSetMacro(PointsFunction, int);
  vtkGetMacro(PointsFunction, int);
84
  //@}
85

86 87 88 89 90
  /**
   * Add a point to the function. Returns the index of the point (0 based),
   * or -1 on error.
   * Subclasses should reimplement this function to do the actual work.
   */
91
  vtkIdType AddPoint(double* newPos) override;
92

93 94 95 96 97
  /**
   * Remove a point of the function. Returns the index of the point (0 based),
   * or -1 on error.
   * Subclasses should reimplement this function to do the actual work.
   */
98
  vtkIdType RemovePoint(double* pos) override;
99

100 101 102 103 104 105 106 107
  //@{
  /**
   * If UseOpacityPointHandles is true, when the current point is
   * double clicked, a vtkPiecewisePointHandleItem will show up so
   * that the sharpness and mid point can be adjusted in the scene
   * with those handles
   * False by default.
   */
108 109
  vtkSetMacro(UseOpacityPointHandles, bool);
  vtkGetMacro(UseOpacityPointHandles, bool);
110
  //@}
111

112 113 114 115
  //@{
  /**
   * Mouse move event. To take care of some special Key stroke
   */
116 117 118
  bool MouseMoveEvent(const vtkContextMouseEvent &mouse) override;
  bool MouseDoubleClickEvent(const vtkContextMouseEvent &mouse) override;
  bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse) override;
119
  //@}
120

121 122
protected:
  vtkCompositeControlPointsItem();
123
  ~vtkCompositeControlPointsItem() override;
124

125
  void emitEvent(unsigned long event, void* params) override;
126

127
  vtkMTimeType GetControlPointsMTime() override;
128

129 130 131 132 133
  vtkIdType GetNumberOfPoints()const override;
  void DrawPoint(vtkContext2D* painter, vtkIdType index) override;
  void GetControlPoint(vtkIdType index, double* pos)const override;
  void SetControlPoint(vtkIdType index, double *point) override;
  void EditPoint(float tX, float tY) override;
134
  virtual void EditPointCurve(vtkIdType idx);
135

136 137
  void MergeTransferFunctions();
  void SilentMergeTransferFunctions();
138

139
  int                   PointsFunction;
140
  vtkPiecewiseFunction* OpacityFunction;
141 142
  vtkPiecewisePointHandleItem* OpacityPointHandle;
  bool UseOpacityPointHandles;
143

144
private:
145 146
  vtkCompositeControlPointsItem(const vtkCompositeControlPointsItem &) = delete;
  void operator=(const vtkCompositeControlPointsItem &) = delete;
147 148 149
};

#endif