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

  Program:   Visualization Toolkit
  Module:    vtkCursor2D.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.

=========================================================================*/
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/**
 * @class   vtkCursor2D
 * @brief   generate a 2D cursor representation
 *
 * vtkCursor2D is a class that generates a 2D cursor representation.
 * The cursor consists of two intersection axes lines that meet at the
 * cursor focus. Several optional features are available as well. An
 * optional 2D bounding box may be enabled. An inner radius, centered at
 * the focal point, can be set that erases the intersecting lines (e.g.,
 * it leaves a clear area under the focal point so you can see
 * what you are selecting). And finally, an optional point can be
 * enabled located at the focal point. All of these features can be turned
 * on and off independently.
 *
*/
30

31 32
#ifndef vtkCursor2D_h
#define vtkCursor2D_h
33

34
#include "vtkFiltersGeneralModule.h" // For export macro
35 36
#include "vtkPolyDataAlgorithm.h"

37
class VTKFILTERSGENERAL_EXPORT vtkCursor2D : public vtkPolyDataAlgorithm
38 39
{
public:
40
  vtkTypeMacro(vtkCursor2D,vtkPolyDataAlgorithm);
41
  void PrintSelf(ostream& os, vtkIndent indent) override;
42

43 44 45 46
  /**
   * Construct with model bounds = (-10,10,-10,10), focal point = (0,0),
   * radius=2, all parts of cursor visible, and wrapping off.
   */
47 48
  static vtkCursor2D *New();

49 50 51 52 53
  //@{
  /**
   * Set / get the bounding box of the 2D cursor. This defines the outline
   * of the cursor, and where the focal point should lie.
   */
54 55
  void SetModelBounds(double xmin, double xmax, double ymin, double ymax,
                      double zmin, double zmax);
56
  void SetModelBounds(const double bounds[6]);
57
  vtkGetVectorMacro(ModelBounds,double,6);
58 59 60 61 62 63 64 65 66 67 68
  //@}

  //@{
  /**
   * Set/Get the position of cursor focus. If translation mode is on,
   * then the entire cursor (including bounding box, cursor, and shadows)
   * is translated. Otherwise, the focal point will either be clamped to the
   * bounding box, or wrapped, if Wrap is on. (Note: this behavior requires
   * that the bounding box is set prior to the focal point.) Note that the
   * method takes a 3D point but ignores the z-coordinate value.
   */
69 70
  void SetFocalPoint(double x[3]);
  void SetFocalPoint(double x, double y, double z)
71
  {
72 73 74
      double xyz[3];
      xyz[0] = x; xyz[1] = y; xyz[2] = z;
      this->SetFocalPoint(xyz);
75
  }
76
  vtkGetVectorMacro(FocalPoint,double,3);
77
  //@}
78

79 80 81 82
  //@{
  /**
   * Turn on/off the wireframe bounding box.
   */
83 84 85
  vtkSetMacro(Outline,vtkTypeBool);
  vtkGetMacro(Outline,vtkTypeBool);
  vtkBooleanMacro(Outline,vtkTypeBool);
86
  //@}
87

88 89 90 91
  //@{
  /**
   * Turn on/off the wireframe axes.
   */
92 93 94
  vtkSetMacro(Axes,vtkTypeBool);
  vtkGetMacro(Axes,vtkTypeBool);
  vtkBooleanMacro(Axes,vtkTypeBool);
95
  //@}
96

97 98 99 100 101
  //@{
  /**
   * Specify a radius for a circle. This erases the cursor
   * lines around the focal point.
   */
102
  vtkSetClampMacro(Radius,double,0.0,VTK_FLOAT_MAX);
103
  vtkGetMacro(Radius,double);
104
  //@}
105

106 107 108 109
  //@{
  /**
   * Turn on/off the point located at the cursor focus.
   */
110 111 112
  vtkSetMacro(Point,vtkTypeBool);
  vtkGetMacro(Point,vtkTypeBool);
  vtkBooleanMacro(Point,vtkTypeBool);
113 114 115 116 117 118 119 120
  //@}

  //@{
  /**
   * Enable/disable the translation mode. If on, changes in cursor position
   * cause the entire widget to translate along with the cursor.
   * By default, translation mode is off.
   */
121 122 123
  vtkSetMacro(TranslationMode,vtkTypeBool);
  vtkGetMacro(TranslationMode,vtkTypeBool);
  vtkBooleanMacro(TranslationMode,vtkTypeBool);
124 125 126 127 128 129 130 131
  //@}

  //@{
  /**
   * Turn on/off cursor wrapping. If the cursor focus moves outside the
   * specified bounds, the cursor will either be restrained against the
   * nearest "wall" (Wrap=off), or it will wrap around (Wrap=on).
   */
132 133 134
  vtkSetMacro(Wrap,vtkTypeBool);
  vtkGetMacro(Wrap,vtkTypeBool);
  vtkBooleanMacro(Wrap,vtkTypeBool);
135
  //@}
136

137 138 139 140
  //@{
  /**
   * Turn every part of the cursor on or off.
   */
141 142
  void AllOn();
  void AllOff();
143
  //@}
144 145 146

protected:
  vtkCursor2D();
147
  ~vtkCursor2D() override {}
148

149
  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
150 151 152

  double ModelBounds[6];
  double FocalPoint[3];
153 154 155
  vtkTypeBool    Outline;
  vtkTypeBool    Axes;
  vtkTypeBool    Point;
156
  double Radius;
157 158
  vtkTypeBool    TranslationMode;
  vtkTypeBool    Wrap;
159

160
private:
161 162
  vtkCursor2D(const vtkCursor2D&) = delete;
  void operator=(const vtkCursor2D&) = delete;
163 164 165
};

#endif