Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / PIPELINE / VISU_SphereWidget.hxx
1 #ifndef __VISU_SphereWidget_h
2 #define __VISU_SphereWidget_h
3
4 #include "VISU_ImplicitFunctionWidget.hxx"
5
6 class VISU_UnScaledActor;
7
8 class vtkActor;
9 class vtkPolyDataMapper;
10 class vtkPoints;
11 class vtkPolyData;
12 class vtkSphereSource;
13 class vtkSphere;
14 class vtkCellPicker;
15 class vtkProperty;
16 class vtkSphere;
17 class vtkImplicitSum;
18 class vtkImplicitFunction;
19 //
20 class VISU_SphereWidget : public VISU_ImplicitFunctionWidget
21 {
22 public:
23   // Description:
24   // Instantiate the object.
25   static VISU_SphereWidget *New();
26   vtkTypeRevisionMacro(VISU_SphereWidget,VISU_ImplicitFunctionWidget);
27   void PrintSelf(ostream& os, vtkIndent indent);
28
29   virtual vtkImplicitFunction* ImplicitFunction();
30   
31   // Description:
32   // Methods that satisfy the superclass' API.
33   virtual void SetEnabled(int);
34   //
35   //PlaceWidget
36   virtual void PlaceWidget(float bounds[6]);
37   //
38   // Description:
39   // Set/Get the resolution of the sphere in the Theta direction.
40   void SetThetaResolution(int r);
41   int GetThetaResolution(); 
42   // Description:
43   // Set/Get the resolution of the sphere in the Phi direction.
44   void SetPhiResolution(int r);
45   int GetPhiResolution();
46
47   // Description:
48   // Set/Get the radius of sphere. Default is .5.
49   void SetRadius(float r); 
50   float GetRadius();
51   
52
53   // Description:
54   // Set/Get the center of the sphere.
55   void SetCenter(float x, float y, float z); 
56   void SetCenter(float x[3]); 
57   
58   float* GetCenter(); 
59   void GetCenter(float xyz[3]); 
60   
61   // Description:
62   // Set the ratio of the radius changing.
63   void SetRatio(float r) { myRatio = r; } 
64   float GetRatio() { return myRatio; } 
65
66   void ChangeRadius(bool up);
67
68   void GetPolyData(vtkPolyData *pd);
69
70   void GetSphere(vtkSphere *sphere);
71
72   
73   vtkProperty* GetSphereProperty ();
74   vtkProperty* GetSelectedSphereProperty ();
75   
76     
77 protected:
78   VISU_SphereWidget();
79   ~VISU_SphereWidget();
80
81   //handles the events
82   static void ProcessEvents(vtkObject* object, 
83                             unsigned long event,
84                             void* clientdata, 
85                             void* calldata);
86
87   // ProcessEvents() dispatches to these methods.
88   void OnLeftButtonDown();
89   void OnLeftButtonUp();
90   void OnMiddleButtonDown();
91   void OnMiddleButtonUp();
92   void OnMouseMove();
93
94   void HighlightSphere(int highlight);
95
96   // Methods to manipulate the sphere widget
97   void Translate(double *p1, double *p2);
98   void Scale(double *p1, double *p2, int X, int Y);
99
100   //virtual void SizeHandles();
101   void CreateDefaultProperties();
102
103   //BTX - manage the state of the widget
104   int myState;
105   enum WidgetState
106   {
107     Start=0,
108     Moving,
109     Scaling,
110     Positioning,
111     Outside
112   };
113   //ETX
114   // the sphere
115   vtkActor       *mySphereActor;
116   vtkPolyDataMapper *mySphereMapper;
117   vtkSphereSource   *mySphereSource;
118   //
119   // the Picker
120   vtkCellPicker *myPicker;
121   // Properties used to control the appearance of selected objects and
122   // the manipulator in general.
123   vtkProperty *mySphereProperty;
124   vtkProperty *mySelectedSphereProperty;
125   float myRmin;
126   vtkSphere *mySphere;
127   vtkImplicitSum* myImplicitSum;
128   float myRatio;
129 private:
130   VISU_SphereWidget(const VISU_SphereWidget&);  //Not implemented
131   void operator=(const VISU_SphereWidget&);  //Not implemented
132 };
133
134 #endif