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