1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkContextMouseEvent.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 /** 17 * @class vtkContextMouseEvent 18 * @brief data structure to represent mouse events. 19 * 20 * 21 * Provides a convenient data structure to represent mouse events in the 22 * vtkContextScene. Passed to vtkAbstractContextItem objects. 23 */ 24 25 #ifndef vtkContextMouseEvent_h 26 #define vtkContextMouseEvent_h 27 28 #include "vtkRenderingContext2DModule.h" // For export macro 29 #include "vtkWin32Header.h" // For export macros. 30 #include "vtkVector.h" // Needed for vtkVector2f and vtkVector2i 31 32 class vtkRenderWindowInteractor; 33 34 class VTKRENDERINGCONTEXT2D_EXPORT vtkContextMouseEvent 35 { 36 public: 37 /** 38 * Enumeration of mouse buttons. 39 */ 40 enum { 41 NO_BUTTON = 0, 42 LEFT_BUTTON = 1, 43 MIDDLE_BUTTON = 2, 44 RIGHT_BUTTON = 4 45 }; 46 47 /** 48 * Enumeration of modifier keys. 49 */ 50 enum { 51 NO_MODIFIER = 0, 52 ALT_MODIFIER = 1, 53 SHIFT_MODIFIER = 2, 54 CONTROL_MODIFIER = 4 55 }; 56 vtkContextMouseEvent()57 vtkContextMouseEvent() 58 { 59 } 60 61 /** 62 * Set the interactor for the mouse event. 63 */ SetInteractor(vtkRenderWindowInteractor * interactor)64 void SetInteractor(vtkRenderWindowInteractor *interactor) 65 { 66 this->Interactor = interactor; 67 } 68 69 /** 70 * Get the interactor for the mouse event. This can be null, and is provided 71 * only for convenience. 72 */ GetInteractor()73 vtkRenderWindowInteractor* GetInteractor() const 74 { 75 return this->Interactor; 76 } 77 78 /** 79 * Set/get the position of the mouse in the item's coordinates. 80 */ SetPos(const vtkVector2f & pos)81 void SetPos(const vtkVector2f &pos) { this->Pos = pos; } GetPos()82 vtkVector2f GetPos() const { return this->Pos; } 83 84 /** 85 * Set/get the position of the mouse in scene coordinates. 86 */ SetScenePos(const vtkVector2f & pos)87 void SetScenePos(const vtkVector2f &pos) { this->ScenePos = pos; } GetScenePos()88 vtkVector2f GetScenePos() const { return this->ScenePos; } 89 90 /** 91 * Set/get the position of the mouse in screen coordinates. 92 */ SetScreenPos(const vtkVector2i & pos)93 void SetScreenPos(const vtkVector2i &pos) { this->ScreenPos = pos; } GetScreenPos()94 vtkVector2i GetScreenPos() const { return this->ScreenPos; } 95 96 /** 97 * Set/get the position of the mouse in the item's coordinates. 98 */ SetLastPos(const vtkVector2f & pos)99 void SetLastPos(const vtkVector2f &pos) { this->LastPos = pos; } GetLastPos()100 vtkVector2f GetLastPos() const { return this->LastPos; } 101 102 /** 103 * Set/get the position of the mouse in scene coordinates. 104 */ SetLastScenePos(const vtkVector2f & pos)105 void SetLastScenePos(const vtkVector2f &pos) { this->LastScenePos = pos; } GetLastScenePos()106 vtkVector2f GetLastScenePos() const { return this->LastScenePos; } 107 108 /** 109 * Set/get the position of the mouse in screen coordinates. 110 */ SetLastScreenPos(const vtkVector2i & pos)111 void SetLastScreenPos(const vtkVector2i &pos) { this->LastScreenPos = pos; } GetLastScreenPos()112 vtkVector2i GetLastScreenPos() const { return this->LastScreenPos; } 113 114 /** 115 * Set/get the mouse button that caused the event, with possible values being 116 * NO_BUTTON, LEFT_BUTTON, MIDDLE_BUTTON and RIGHT_BUTTON. 117 */ SetButton(int button)118 void SetButton(int button) { this->Button = button; } GetButton()119 int GetButton() const { return this->Button; } 120 121 /** 122 * Return the modifier keys, if any, ORed together. Valid modifier enum values 123 * are NO_MODIFIER, ALT_MODIFIER, SHIFT_MODIFIER and/or CONTROL_MODIFIER. 124 */ 125 int GetModifiers() const; 126 127 protected: 128 /** 129 * Position of the mouse in item coordinate system. 130 */ 131 vtkVector2f Pos; 132 133 /** 134 * Position of the mouse the scene coordinate system. 135 */ 136 vtkVector2f ScenePos; 137 138 /** 139 * Position of the mouse in screen coordinates 140 */ 141 vtkVector2i ScreenPos; 142 143 /** 144 * `Pos' at the previous mouse event. 145 */ 146 vtkVector2f LastPos; 147 148 /** 149 * `ScenePos'at the previous mouse event. 150 */ 151 vtkVector2f LastScenePos; 152 153 /** 154 * `ScreenPos' at the previous mouse event. 155 */ 156 vtkVector2i LastScreenPos; 157 158 /** 159 * Mouse button that caused the event, using the anonymous enumeration. 160 */ 161 int Button; 162 163 protected: 164 vtkRenderWindowInteractor *Interactor; 165 }; 166 167 #endif // vtkContextMouseEvent_h 168 // VTK-HeaderTest-Exclude: vtkContextMouseEvent.h 169