1 // Copyright (C) 2007-2010 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
23 #ifndef __VISU_SphereWidget_h
24 #define __VISU_SphereWidget_h
26 #include "VISUPipeline.hxx"
27 #include "VISU_ImplicitFunctionWidget.hxx"
29 class VISU_UnScaledActor;
32 class vtkPolyDataMapper;
35 class vtkSphereSource;
41 class vtkImplicitFunction;
43 class VISU_PIPELINE_EXPORT VISU_SphereWidget : public VISU_ImplicitFunctionWidget
47 // Instantiate the object.
48 static VISU_SphereWidget *New();
49 vtkTypeRevisionMacro(VISU_SphereWidget,VISU_ImplicitFunctionWidget);
50 void PrintSelf(ostream& os, vtkIndent indent);
52 virtual vtkImplicitFunction* ImplicitFunction();
55 // Methods that satisfy the superclass' API.
56 virtual void SetEnabled(int);
59 virtual void PlaceWidget(vtkFloatingPointType bounds[6]);
62 // Set/Get the resolution of the sphere in the Theta direction.
63 void SetThetaResolution(int r);
64 int GetThetaResolution();
66 // Set/Get the resolution of the sphere in the Phi direction.
67 void SetPhiResolution(int r);
68 int GetPhiResolution();
71 // Set/Get the radius of sphere. Default is .5.
72 void SetRadius(vtkFloatingPointType r);
73 vtkFloatingPointType GetRadius();
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]);
83 vtkFloatingPointType* GetCenter();
84 void GetCenter(vtkFloatingPointType xyz[3]);
87 // Set the ratio of the radius changing.
88 void SetRatio(vtkFloatingPointType r) { myRatio = r; }
89 vtkFloatingPointType GetRatio() { return myRatio; }
91 void ChangeRadius(bool up);
93 void GetPolyData(vtkPolyData *pd);
95 void GetSphere(vtkSphere *sphere);
98 vtkProperty* GetSphereProperty ();
99 vtkProperty* GetSelectedSphereProperty ();
104 ~VISU_SphereWidget();
107 static void ProcessEvents(vtkObject* object,
112 // ProcessEvents() dispatches to these methods.
113 void OnLeftButtonDown();
114 void OnLeftButtonUp();
115 void OnMiddleButtonDown();
116 void OnMiddleButtonUp();
119 void HighlightSphere(int highlight);
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);
125 //virtual void SizeHandles();
126 void CreateDefaultProperties();
128 //BTX - manage the state of the widget
140 vtkActor *mySphereActor;
141 vtkPolyDataMapper *mySphereMapper;
142 vtkSphereSource *mySphereSource;
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;
152 vtkImplicitSum* myImplicitSum;
153 vtkFloatingPointType myRatio;
155 VISU_SphereWidget(const VISU_SphereWidget&); //Not implemented
156 void operator=(const VISU_SphereWidget&); //Not implemented