1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #ifndef __VISU_SphereWidget_h
23 #define __VISU_SphereWidget_h
25 #include "VISUPipeline.hxx"
26 #include "VISU_ImplicitFunctionWidget.hxx"
28 class VISU_UnScaledActor;
31 class vtkPolyDataMapper;
34 class vtkSphereSource;
40 class vtkImplicitFunction;
42 class VISU_PIPELINE_EXPORT VISU_SphereWidget : public VISU_ImplicitFunctionWidget
46 // Instantiate the object.
47 static VISU_SphereWidget *New();
48 vtkTypeRevisionMacro(VISU_SphereWidget,VISU_ImplicitFunctionWidget);
49 void PrintSelf(ostream& os, vtkIndent indent);
51 virtual vtkImplicitFunction* ImplicitFunction();
54 // Methods that satisfy the superclass' API.
55 virtual void SetEnabled(int);
58 virtual void PlaceWidget(vtkFloatingPointType bounds[6]);
61 // Set/Get the resolution of the sphere in the Theta direction.
62 void SetThetaResolution(int r);
63 int GetThetaResolution();
65 // Set/Get the resolution of the sphere in the Phi direction.
66 void SetPhiResolution(int r);
67 int GetPhiResolution();
70 // Set/Get the radius of sphere. Default is .5.
71 void SetRadius(vtkFloatingPointType r);
72 vtkFloatingPointType GetRadius();
76 // Set/Get the center of the sphere.
77 void SetCenter(vtkFloatingPointType x,
78 vtkFloatingPointType y,
79 vtkFloatingPointType z);
80 void SetCenter(vtkFloatingPointType x[3]);
82 vtkFloatingPointType* GetCenter();
83 void GetCenter(vtkFloatingPointType xyz[3]);
86 // Set the ratio of the radius changing.
87 void SetRatio(vtkFloatingPointType r) { myRatio = r; }
88 vtkFloatingPointType GetRatio() { return myRatio; }
90 void ChangeRadius(bool up);
92 void GetPolyData(vtkPolyData *pd);
94 void GetSphere(vtkSphere *sphere);
97 vtkProperty* GetSphereProperty ();
98 vtkProperty* GetSelectedSphereProperty ();
103 ~VISU_SphereWidget();
106 static void ProcessEvents(vtkObject* object,
111 // ProcessEvents() dispatches to these methods.
112 void OnLeftButtonDown();
113 void OnLeftButtonUp();
114 void OnMiddleButtonDown();
115 void OnMiddleButtonUp();
118 void HighlightSphere(int highlight);
120 // Methods to manipulate the sphere widget
121 void Translate(double *p1, double *p2);
122 void Scale(double *p1, double *p2, int X, int Y);
124 //virtual void SizeHandles();
125 void CreateDefaultProperties();
127 //BTX - manage the state of the widget
139 vtkActor *mySphereActor;
140 vtkPolyDataMapper *mySphereMapper;
141 vtkSphereSource *mySphereSource;
144 vtkCellPicker *myPicker;
145 // Properties used to control the appearance of selected objects and
146 // the manipulator in general.
147 vtkProperty *mySphereProperty;
148 vtkProperty *mySelectedSphereProperty;
149 vtkFloatingPointType myRmin;
151 vtkImplicitSum* myImplicitSum;
152 vtkFloatingPointType myRatio;
154 VISU_SphereWidget(const VISU_SphereWidget&); //Not implemented
155 void operator=(const VISU_SphereWidget&); //Not implemented