Salome HOME
6dcba37feb4343aafdc109ed03a9c859cca4a01f
[modules/visu.git] / src / PIPELINE / VISU_SphereWidget.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
8 //
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/
19 //
20 #ifndef __VISU_SphereWidget_h
21 #define __VISU_SphereWidget_h
22
23 #include "VISU_ImplicitFunctionWidget.hxx"
24
25 class VISU_UnScaledActor;
26
27 class vtkActor;
28 class vtkPolyDataMapper;
29 class vtkPoints;
30 class vtkPolyData;
31 class vtkSphereSource;
32 class vtkSphere;
33 class vtkCellPicker;
34 class vtkProperty;
35 class vtkSphere;
36 class vtkImplicitSum;
37 class vtkImplicitFunction;
38 //
39 class VISU_SphereWidget : public VISU_ImplicitFunctionWidget
40 {
41 public:
42   // Description:
43   // Instantiate the object.
44   static VISU_SphereWidget *New();
45   vtkTypeRevisionMacro(VISU_SphereWidget,VISU_ImplicitFunctionWidget);
46   void PrintSelf(ostream& os, vtkIndent indent);
47
48   virtual vtkImplicitFunction* ImplicitFunction();
49   
50   // Description:
51   // Methods that satisfy the superclass' API.
52   virtual void SetEnabled(int);
53   //
54   //PlaceWidget
55   virtual void PlaceWidget(vtkFloatingPointType bounds[6]);
56   //
57   // Description:
58   // Set/Get the resolution of the sphere in the Theta direction.
59   void SetThetaResolution(int r);
60   int GetThetaResolution(); 
61   // Description:
62   // Set/Get the resolution of the sphere in the Phi direction.
63   void SetPhiResolution(int r);
64   int GetPhiResolution();
65
66   // Description:
67   // Set/Get the radius of sphere. Default is .5.
68   void SetRadius(vtkFloatingPointType r); 
69   vtkFloatingPointType GetRadius();
70   
71
72   // Description:
73   // Set/Get the center of the sphere.
74   void SetCenter(vtkFloatingPointType x, 
75                  vtkFloatingPointType y, 
76                  vtkFloatingPointType z); 
77   void SetCenter(vtkFloatingPointType x[3]); 
78   
79   vtkFloatingPointType* GetCenter(); 
80   void GetCenter(vtkFloatingPointType xyz[3]); 
81   
82   // Description:
83   // Set the ratio of the radius changing.
84   void SetRatio(vtkFloatingPointType r) { myRatio = r; } 
85   vtkFloatingPointType GetRatio() { return myRatio; } 
86
87   void ChangeRadius(bool up);
88
89   void GetPolyData(vtkPolyData *pd);
90
91   void GetSphere(vtkSphere *sphere);
92
93   
94   vtkProperty* GetSphereProperty ();
95   vtkProperty* GetSelectedSphereProperty ();
96   
97     
98 protected:
99   VISU_SphereWidget();
100   ~VISU_SphereWidget();
101
102   //handles the events
103   static void ProcessEvents(vtkObject* object, 
104                             unsigned long event,
105                             void* clientdata, 
106                             void* calldata);
107
108   // ProcessEvents() dispatches to these methods.
109   void OnLeftButtonDown();
110   void OnLeftButtonUp();
111   void OnMiddleButtonDown();
112   void OnMiddleButtonUp();
113   void OnMouseMove();
114
115   void HighlightSphere(int highlight);
116
117   // Methods to manipulate the sphere widget
118   void Translate(double *p1, double *p2);
119   void Scale(double *p1, double *p2, int X, int Y);
120
121   //virtual void SizeHandles();
122   void CreateDefaultProperties();
123
124   //BTX - manage the state of the widget
125   int myState;
126   enum WidgetState
127   {
128     Start=0,
129     Moving,
130     Scaling,
131     Positioning,
132     Outside
133   };
134   //ETX
135   // the sphere
136   vtkActor       *mySphereActor;
137   vtkPolyDataMapper *mySphereMapper;
138   vtkSphereSource   *mySphereSource;
139   //
140   // the Picker
141   vtkCellPicker *myPicker;
142   // Properties used to control the appearance of selected objects and
143   // the manipulator in general.
144   vtkProperty *mySphereProperty;
145   vtkProperty *mySelectedSphereProperty;
146   vtkFloatingPointType myRmin;
147   vtkSphere *mySphere;
148   vtkImplicitSum* myImplicitSum;
149   vtkFloatingPointType myRatio;
150 private:
151   VISU_SphereWidget(const VISU_SphereWidget&);  //Not implemented
152   void operator=(const VISU_SphereWidget&);  //Not implemented
153 };
154
155 #endif