vtkColorTransferControlPointsItem.h 4.01 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*=========================================================================

  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.

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

// .NAME vtkColorTransferControlPointsItem - Control points for
// vtkColorTransferFunction.
// .SECTION Description
// vtkColorTransferControlPointsItem draws the control points of a vtkColorTransferFunction.
// .SECTION See Also
// vtkControlPointsItem
// vtkColorTransferFunctionItem
// vtkCompositeTransferFunctionItem

25 26
#ifndef vtkColorTransferControlPointsItem_h
#define vtkColorTransferControlPointsItem_h
27

28
#include "vtkChartsCoreModule.h" // For export macro
29 30 31 32
#include "vtkControlPointsItem.h"

class vtkColorTransferFunction;

33
class VTKCHARTSCORE_EXPORT vtkColorTransferControlPointsItem: public vtkControlPointsItem
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
{
public:
  vtkTypeMacro(vtkColorTransferControlPointsItem, vtkControlPointsItem);
  virtual void PrintSelf(ostream &os, vtkIndent indent);

  // Description:
  // Creates a piecewise control points object
  static vtkColorTransferControlPointsItem* New();

  // Description:
  // Set the piecewise function to draw its points
  void SetColorTransferFunction(vtkColorTransferFunction* function);
  // Description
  // Get the piecewise function
  vtkGetObjectMacro(ColorTransferFunction, vtkColorTransferFunction);

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
  // Description
  // Return the number of points in the color transfer function.
  virtual vtkIdType GetNumberOfPoints()const;

  // Description
  // 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
  virtual void GetControlPoint(vtkIdType index, double *point)const;

  // Description:
  // 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
  virtual void SetControlPoint(vtkIdType index, double *point);

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
  // Description:
  // 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.
  virtual vtkIdType AddPoint(double* newPos);

  // Description:
  // 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.
  virtual vtkIdType RemovePoint(double* pos);

  // Description:
  // If ColorFill is true, the control point brush color is set with the
  // matching color in the color transfer function.
  // False by default.
  vtkSetMacro(ColorFill, bool);
  vtkGetMacro(ColorFill, bool);

protected:
  vtkColorTransferControlPointsItem();
  virtual ~vtkColorTransferControlPointsItem();

89 90 91 92 93 94
  // Description:
  // Returns true if control points are to be rendered in log-space. This is
  // true when vtkScalarsToColors is using log-scale, for example. Default
  // implementation always return false.
  virtual bool UsingLogScale();

95
  virtual void emitEvent(unsigned long event, void* params);
96

97 98 99 100 101
  virtual unsigned long int GetControlPointsMTime();

  virtual void DrawPoint(vtkContext2D* painter, vtkIdType index);
  virtual void EditPoint(float tX, float tY);

102 103 104 105 106
  // Description:
  // Compute the bounds for this item. Overridden to use the
  // vtkColorTransferFunction range.
  virtual void ComputeBounds(double* bounds);

107 108 109 110 111 112 113 114 115
  vtkColorTransferFunction* ColorTransferFunction;

  bool ColorFill;
private:
  vtkColorTransferControlPointsItem(const vtkColorTransferControlPointsItem &); // Not implemented.
  void operator=(const vtkColorTransferControlPointsItem &);   // Not implemented.
};

#endif