1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef __VISU_SphereWidget_h
21 #define __VISU_SphereWidget_h
23 #include "VISU_ImplicitFunctionWidget.hxx"
25 class VISU_UnScaledActor;
28 class vtkPolyDataMapper;
31 class vtkSphereSource;
37 class vtkImplicitFunction;
39 class VISU_SphereWidget : public VISU_ImplicitFunctionWidget
43 // Instantiate the object.
44 static VISU_SphereWidget *New();
45 vtkTypeRevisionMacro(VISU_SphereWidget,VISU_ImplicitFunctionWidget);
46 void PrintSelf(ostream& os, vtkIndent indent);
48 virtual vtkImplicitFunction* ImplicitFunction();
51 // Methods that satisfy the superclass' API.
52 virtual void SetEnabled(int);
55 virtual void PlaceWidget(vtkFloatingPointType bounds[6]);
58 // Set/Get the resolution of the sphere in the Theta direction.
59 void SetThetaResolution(int r);
60 int GetThetaResolution();
62 // Set/Get the resolution of the sphere in the Phi direction.
63 void SetPhiResolution(int r);
64 int GetPhiResolution();
67 // Set/Get the radius of sphere. Default is .5.
68 void SetRadius(vtkFloatingPointType r);
69 vtkFloatingPointType GetRadius();
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]);
79 vtkFloatingPointType* GetCenter();
80 void GetCenter(vtkFloatingPointType xyz[3]);
83 // Set the ratio of the radius changing.
84 void SetRatio(vtkFloatingPointType r) { myRatio = r; }
85 vtkFloatingPointType GetRatio() { return myRatio; }
87 void ChangeRadius(bool up);
89 void GetPolyData(vtkPolyData *pd);
91 void GetSphere(vtkSphere *sphere);
94 vtkProperty* GetSphereProperty ();
95 vtkProperty* GetSelectedSphereProperty ();
100 ~VISU_SphereWidget();
103 static void ProcessEvents(vtkObject* object,
108 // ProcessEvents() dispatches to these methods.
109 void OnLeftButtonDown();
110 void OnLeftButtonUp();
111 void OnMiddleButtonDown();
112 void OnMiddleButtonUp();
115 void HighlightSphere(int highlight);
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);
121 //virtual void SizeHandles();
122 void CreateDefaultProperties();
124 //BTX - manage the state of the widget
136 vtkActor *mySphereActor;
137 vtkPolyDataMapper *mySphereMapper;
138 vtkSphereSource *mySphereSource;
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;
148 vtkImplicitSum* myImplicitSum;
149 vtkFloatingPointType myRatio;
151 VISU_SphereWidget(const VISU_SphereWidget&); //Not implemented
152 void operator=(const VISU_SphereWidget&); //Not implemented