OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkScalarBarWidget.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkScalarBarWidget.h,v $
5   Language:  C++
6   Date:      $Date: 2003/01/07 16:16:56 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
13      This software is distributed WITHOUT ANY WARRANTY; without even 
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15      PURPOSE.  See the above copyright notice for more information.
16
17 =========================================================================*/
18 // .NAME vtkScalarBarWidget - 2D widget for manipulating a scalar bar
19 // .SECTION Description
20 // This class provides support for interactively manipulating the position,
21 // size, and orientation of a scalar bar. It listens to Left mouse events and
22 // mouse movement. It also listens to Right mouse events and notifies any 
23 // observers of Right mouse events on this object when they occur.
24 // It will change the cursor shape based on its location. If
25 // the cursor is over an edge of the scalar bar it will change the cursor
26 // shape to a resize edge shape. If the position of a scalar bar is moved to
27 // be close to the center of one of the four edges of the viewport, then the
28 // scalar bar will change its orientation to align with that edge. This
29 // orientation is sticky in that it will stay that orientation until the
30 // position is moved close to another edge.
31
32 // .SECTION See Also
33 // vtkInteractorObserver
34
35
36 #ifndef __vtkScalarBarWidget_h
37 #define __vtkScalarBarWidget_h
38
39 #include "vtkInteractorObserver.h"
40 class vtkScalarBarActor;
41
42 class VTK_HYBRID_EXPORT vtkScalarBarWidget : public vtkInteractorObserver
43 {
44 public:
45   static vtkScalarBarWidget *New();
46   vtkTypeRevisionMacro(vtkScalarBarWidget,vtkInteractorObserver);
47   void PrintSelf(ostream& os, vtkIndent indent);
48
49   // Description:
50   // Get the ScalarBar used by this Widget. One is created automatically.
51   void SetScalarBarActor(vtkScalarBarActor *scalarbar);
52   vtkGetObjectMacro(ScalarBarActor,vtkScalarBarActor);
53   
54   // Description:
55   // Methods for turning the interactor observer on and off.
56   virtual void SetEnabled(int);
57
58 protected:
59   vtkScalarBarWidget();
60   ~vtkScalarBarWidget();
61
62   // the actor that is used
63   vtkScalarBarActor *ScalarBarActor;
64
65   //handles the events
66   static void ProcessEvents(vtkObject* object, 
67                             unsigned long event,
68                             void* clientdata, 
69                             void* calldata);
70
71   // ProcessEvents() dispatches to these methods.
72   void OnLeftButtonDown();
73   void OnLeftButtonUp();
74   void OnRightButtonDown();
75   void OnRightButtonUp();
76   void OnMouseMove();
77
78   // used to compute relative movements
79   float StartPosition[2];
80   
81 //BTX - manage the state of the widget
82   int State;
83   // use this to track whether left/right button was pressed to gate
84   // action on button up event.
85   int LeftButtonDown;
86   int RightButtonDown;
87   enum WidgetState
88   {
89     Moving=0,
90     AdjustingP1,
91     AdjustingP2,
92     AdjustingP3,
93     AdjustingP4,
94     AdjustingE1,
95     AdjustingE2,
96     AdjustingE3,
97     AdjustingE4,
98     Inside,
99     Outside
100   };
101 //ETX
102
103   // use to determine what state the mouse is over, edge1 p1, etc.
104   // returns a state from the WidgetState enum above
105   int ComputeStateBasedOnPosition(int X, int Y, int *pos1, int *pos2);
106
107   // set the cursor to the correct shape based on State argument
108   void SetCursor(int State);
109
110 private:
111   vtkScalarBarWidget(const vtkScalarBarWidget&);  //Not implemented
112   void operator=(const vtkScalarBarWidget&);  //Not implemented
113 };
114
115 #endif