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

  Program:   Visualization Toolkit
  Module:    vtkColorTransferControlPointsItem.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
/**
 * @class   vtkColorTransferControlPointsItem
 * @brief   Control points for
 * vtkColorTransferFunction.
 *
 * vtkColorTransferControlPointsItem draws the control points of a vtkColorTransferFunction.
 * @sa
 * vtkControlPointsItem
 * vtkColorTransferFunctionItem
 * vtkCompositeTransferFunctionItem
*/
27

28 29
#ifndef vtkColorTransferControlPointsItem_h
#define vtkColorTransferControlPointsItem_h
30

31
#include "vtkChartsCoreModule.h" // For export macro
32 33 34 35
#include "vtkControlPointsItem.h"

class vtkColorTransferFunction;

36
class VTKCHARTSCORE_EXPORT vtkColorTransferControlPointsItem: public vtkControlPointsItem
37 38 39
{
public:
  vtkTypeMacro(vtkColorTransferControlPointsItem, vtkControlPointsItem);
40
  void PrintSelf(ostream &os, vtkIndent indent) override;
41

42 43 44
  /**
   * Creates a piecewise control points object
   */
45 46
  static vtkColorTransferControlPointsItem* New();

47 48 49
  /**
   * Set the piecewise function to draw its points
   */
50
  void SetColorTransferFunction(vtkColorTransferFunction* function);
51 52 53 54
  //@{
  /**
   * Get the piecewise function
   */
55
  vtkGetObjectMacro(ColorTransferFunction, vtkColorTransferFunction);
56
  //@}
57

58 59 60
  /**
   * Return the number of points in the color transfer function.
   */
61
  vtkIdType GetNumberOfPoints()const override;
62

63 64 65 66 67
  /**
   * Returns the x and y coordinates as well as the midpoint and sharpness
   * of the control point corresponding to the index.
   * Note: The y (point[1]) is always 0.5
   */
68
  void GetControlPoint(vtkIdType index, double *point)const override;
69

70 71 72 73 74
  /**
   * Sets the x and y coordinates as well as the midpoint and sharpness
   * of the control point corresponding to the index.
   * Changing the y has no effect, it will always be 0.5
   */
75
  void SetControlPoint(vtkIdType index, double *point) override;
76

77 78 79 80 81
  /**
   * 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.
   */
82
  vtkIdType AddPoint(double* newPos) override;
83

84 85 86 87 88
  /**
   * 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.
   */
89
  vtkIdType RemovePoint(double* pos) override;
90

91 92 93 94 95 96
  //@{
  /**
   * If ColorFill is true, the control point brush color is set with the
   * matching color in the color transfer function.
   * False by default.
   */
97 98
  vtkSetMacro(ColorFill, bool);
  vtkGetMacro(ColorFill, bool);
99
  //@}
100 101 102

protected:
  vtkColorTransferControlPointsItem();
103
  ~vtkColorTransferControlPointsItem() override;
104

105
  void emitEvent(unsigned long event, void* params) override;
106

107
  vtkMTimeType GetControlPointsMTime() override;
108

109 110
  void DrawPoint(vtkContext2D* painter, vtkIdType index) override;
  void EditPoint(float tX, float tY) override;
111

112 113 114 115
  /**
   * Compute the bounds for this item. Overridden to use the
   * vtkColorTransferFunction range.
   */
116
  void ComputeBounds(double* bounds) override;
117

118 119 120 121
  vtkColorTransferFunction* ColorTransferFunction;

  bool ColorFill;
private:
122 123
  vtkColorTransferControlPointsItem(const vtkColorTransferControlPointsItem &) = delete;
  void operator=(const vtkColorTransferControlPointsItem &) = delete;
124 125 126
};

#endif