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