1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkAffineRepresentation.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /**
16  * @class   vtkAffineRepresentation
17  * @brief   abstract class for representing affine transformation widgets
18  *
19  * This class defines an API for affine transformation widget
20  * representations. These representations interact with vtkAffineWidget. The
21  * basic functionality of the affine representation is to maintain a
22  * transformation matrix.
23  *
24  * This class may be subclassed so that alternative representations can
25  * be created.  The class defines an API and a default implementation that
26  * the vtkAffineWidget interacts with to render itself in the scene.
27  *
28  * @warning
29  * The separation of the widget event handling and representation enables
30  * users and developers to create new appearances for the widget. It also
31  * facilitates parallel processing, where the client application handles
32  * events, and remote representations of the widget are slaves to the
33  * client (and do not handle events).
34  *
35  * @sa
36  * vtkAffineWidget vtkWidgetRepresentation vtkAbstractWidget
37 */
38 
39 #ifndef vtkAffineRepresentation_h
40 #define vtkAffineRepresentation_h
41 
42 #include "vtkInteractionWidgetsModule.h" // For export macro
43 #include "vtkWidgetRepresentation.h"
44 
45 class vtkTransform;
46 
47 class VTKINTERACTIONWIDGETS_EXPORT vtkAffineRepresentation : public vtkWidgetRepresentation
48 {
49 public:
50   //@{
51   /**
52    * Standard methods for instances of this class.
53    */
54   vtkTypeMacro(vtkAffineRepresentation,vtkWidgetRepresentation);
55   void PrintSelf(ostream& os, vtkIndent indent) override;
56   //@}
57 
58   /**
59    * Retrieve a linear transform characterizing the affine transformation
60    * generated by this widget. This method copies its internal transform into
61    * the transform provided. The transform is relative to the initial placement
62    * of the representation (i.e., when PlaceWidget() is invoked).
63    */
64   virtual void GetTransform(vtkTransform *t) = 0;
65 
66   //@{
67   /**
68    * The tolerance representing the distance to the widget (in pixels)
69    * in which the cursor is considered near enough to the widget to
70    * be active.
71    */
72   vtkSetClampMacro(Tolerance,int,1,100);
73   vtkGetMacro(Tolerance,int);
74   //@}
75 
76   // Enums define the state of the representation relative to the mouse pointer
77   // position. Used by ComputeInteractionState() to communicate with the
78   // widget.
79   enum _InteractionState
80   {
81     Outside=0, Rotate, Translate, TranslateX, TranslateY, ScaleWEdge, ScaleEEdge,
82     ScaleNEdge, ScaleSEdge, ScaleNE, ScaleSW, ScaleNW, ScaleSE,
83     ShearEEdge, ShearWEdge, ShearNEdge, ShearSEdge,
84     MoveOriginX, MoveOriginY, MoveOrigin
85   };
86 
87   /**
88    * Methods to make this class properly act like a vtkWidgetRepresentation.
89    */
90   void ShallowCopy(vtkProp *prop) override;
91 
92 protected:
93   vtkAffineRepresentation();
94   ~vtkAffineRepresentation() override;
95 
96   // The tolerance for selecting different parts of the widget.
97   int Tolerance;
98 
99   // The internal transformation matrix
100   vtkTransform *Transform;
101 
102 private:
103   vtkAffineRepresentation(const vtkAffineRepresentation&) = delete;
104   void operator=(const vtkAffineRepresentation&) = delete;
105 };
106 
107 #endif
108