1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkXYPlotWidget.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 vtkXYPlotWidget 17 * @brief 2D widget for manipulating a XY plot 18 * 19 * This class provides support for interactively manipulating the position, 20 * size, and orientation of a XY Plot. It listens to Left mouse events and 21 * mouse movement. It will change the cursor shape based on its location. If 22 * the cursor is over an edge of thea XY plot it will change the cursor shape 23 * to a resize edge shape. If the position of a XY plot is moved to be close to 24 * the center of one of the four edges of the viewport, then the XY plot will 25 * change its orientation to align with that edge. This orientation is sticky 26 * in that it will stay that orientation until the position is moved close to 27 * another edge. 28 * 29 * @sa 30 * vtkInteractorObserver 31 */ 32 33 #ifndef vtkXYPlotWidget_h 34 #define vtkXYPlotWidget_h 35 36 #include "vtkInteractionWidgetsModule.h" // For export macro 37 #include "vtkInteractorObserver.h" 38 class vtkXYPlotActor; 39 40 class VTKINTERACTIONWIDGETS_EXPORT vtkXYPlotWidget : public vtkInteractorObserver 41 { 42 public: 43 static vtkXYPlotWidget *New(); 44 vtkTypeMacro(vtkXYPlotWidget,vtkInteractorObserver); 45 void PrintSelf(ostream& os, vtkIndent indent) override; 46 47 //@{ 48 /** 49 * Get the XY plot used by this Widget. One is created automatically. 50 */ 51 virtual void SetXYPlotActor(vtkXYPlotActor *); 52 vtkGetObjectMacro(XYPlotActor,vtkXYPlotActor); 53 //@} 54 55 /** 56 * Methods for turning the interactor observer on and off. 57 */ 58 void SetEnabled(int) override; 59 60 protected: 61 vtkXYPlotWidget(); 62 ~vtkXYPlotWidget() override; 63 64 // the actor that is used 65 vtkXYPlotActor *XYPlotActor; 66 67 //handles the events 68 static void ProcessEvents(vtkObject* object, 69 unsigned long event, 70 void* clientdata, 71 void* calldata); 72 73 // ProcessEvents() dispatches to these methods. 74 void OnLeftButtonDown(); 75 void OnLeftButtonUp(); 76 void OnMouseMove(); 77 78 // used to compute relative movements 79 float StartPosition[2]; 80 81 // Manage the state of the widget 82 int State; 83 enum WidgetState 84 { 85 Moving=0, 86 AdjustingP1, 87 AdjustingP2, 88 AdjustingP3, 89 AdjustingP4, 90 AdjustingE1, 91 AdjustingE2, 92 AdjustingE3, 93 AdjustingE4, 94 Inside, 95 Outside 96 }; 97 98 // use to determine what state the mouse is over, edge1 p1, etc. 99 // returns a state from the WidgetState enum above 100 int ComputeStateBasedOnPosition(int X, int Y, int *pos1, int *pos2); 101 102 // set the cursor to the correct shape based on State argument 103 void SetCursor(int State); 104 105 private: 106 vtkXYPlotWidget(const vtkXYPlotWidget&) = delete; 107 void operator=(const vtkXYPlotWidget&) = delete; 108 }; 109 110 #endif 111