1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkScalarBarWidget.h,v $
6 Date: $Date: 2003/01/07 16:16:56 $
7 Version: $Revision: 1.4 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
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.
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.
33 // vtkInteractorObserver
36 #ifndef __vtkScalarBarWidget_h
37 #define __vtkScalarBarWidget_h
39 #include "vtkInteractorObserver.h"
40 class vtkScalarBarActor;
42 class VTK_HYBRID_EXPORT vtkScalarBarWidget : public vtkInteractorObserver
45 static vtkScalarBarWidget *New();
46 vtkTypeRevisionMacro(vtkScalarBarWidget,vtkInteractorObserver);
47 void PrintSelf(ostream& os, vtkIndent indent);
50 // Get the ScalarBar used by this Widget. One is created automatically.
51 void SetScalarBarActor(vtkScalarBarActor *scalarbar);
52 vtkGetObjectMacro(ScalarBarActor,vtkScalarBarActor);
55 // Methods for turning the interactor observer on and off.
56 virtual void SetEnabled(int);
60 ~vtkScalarBarWidget();
62 // the actor that is used
63 vtkScalarBarActor *ScalarBarActor;
66 static void ProcessEvents(vtkObject* object,
71 // ProcessEvents() dispatches to these methods.
72 void OnLeftButtonDown();
73 void OnLeftButtonUp();
74 void OnRightButtonDown();
75 void OnRightButtonUp();
78 // used to compute relative movements
79 float StartPosition[2];
81 //BTX - manage the state of the widget
83 // use this to track whether left/right button was pressed to gate
84 // action on button up event.
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);
107 // set the cursor to the correct shape based on State argument
108 void SetCursor(int State);
111 vtkScalarBarWidget(const vtkScalarBarWidget&); //Not implemented
112 void operator=(const vtkScalarBarWidget&); //Not implemented