Version: 6.3.1

src/PIPELINE/VISU_SphereWidget.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef __VISU_SphereWidget_h
00024 #define __VISU_SphereWidget_h
00025 
00026 #include "VISUPipeline.hxx"
00027 #include "VISU_ImplicitFunctionWidget.hxx"
00028 
00029 class VISU_UnScaledActor;
00030 
00031 class vtkActor;
00032 class vtkPolyDataMapper;
00033 class vtkPoints;
00034 class vtkPolyData;
00035 class vtkSphereSource;
00036 class vtkSphere;
00037 class vtkCellPicker;
00038 class vtkProperty;
00039 class vtkSphere;
00040 class vtkImplicitSum;
00041 class vtkImplicitFunction;
00042 //
00043 class VISU_PIPELINE_EXPORT VISU_SphereWidget : public VISU_ImplicitFunctionWidget
00044 {
00045 public:
00046   // Description:
00047   // Instantiate the object.
00048   static VISU_SphereWidget *New();
00049   vtkTypeRevisionMacro(VISU_SphereWidget,VISU_ImplicitFunctionWidget);
00050   void PrintSelf(ostream& os, vtkIndent indent);
00051 
00052   virtual vtkImplicitFunction* ImplicitFunction();
00053   
00054   // Description:
00055   // Methods that satisfy the superclass' API.
00056   virtual void SetEnabled(int);
00057   //
00058   //PlaceWidget
00059   virtual void PlaceWidget(vtkFloatingPointType bounds[6]);
00060   //
00061   // Description:
00062   // Set/Get the resolution of the sphere in the Theta direction.
00063   void SetThetaResolution(int r);
00064   int GetThetaResolution(); 
00065   // Description:
00066   // Set/Get the resolution of the sphere in the Phi direction.
00067   void SetPhiResolution(int r);
00068   int GetPhiResolution();
00069 
00070   // Description:
00071   // Set/Get the radius of sphere. Default is .5.
00072   void SetRadius(vtkFloatingPointType r); 
00073   vtkFloatingPointType GetRadius();
00074   
00075 
00076   // Description:
00077   // Set/Get the center of the sphere.
00078   void SetCenter(vtkFloatingPointType x, 
00079                  vtkFloatingPointType y, 
00080                  vtkFloatingPointType z); 
00081   void SetCenter(vtkFloatingPointType x[3]); 
00082   
00083   vtkFloatingPointType* GetCenter(); 
00084   void GetCenter(vtkFloatingPointType xyz[3]); 
00085   
00086   // Description:
00087   // Set the ratio of the radius changing.
00088   void SetRatio(vtkFloatingPointType r) { myRatio = r; } 
00089   vtkFloatingPointType GetRatio() { return myRatio; } 
00090 
00091   void ChangeRadius(bool up);
00092 
00093   void GetPolyData(vtkPolyData *pd);
00094 
00095   void GetSphere(vtkSphere *sphere);
00096 
00097   
00098   vtkProperty* GetSphereProperty ();
00099   vtkProperty* GetSelectedSphereProperty ();
00100   
00101     
00102 protected:
00103   VISU_SphereWidget();
00104   ~VISU_SphereWidget();
00105 
00106   //handles the events
00107   static void ProcessEvents(vtkObject* object, 
00108                             unsigned long event,
00109                             void* clientdata, 
00110                             void* calldata);
00111 
00112   // ProcessEvents() dispatches to these methods.
00113   void OnLeftButtonDown();
00114   void OnLeftButtonUp();
00115   void OnMiddleButtonDown();
00116   void OnMiddleButtonUp();
00117   void OnMouseMove();
00118 
00119   void HighlightSphere(int highlight);
00120 
00121   // Methods to manipulate the sphere widget
00122   void Translate(double *p1, double *p2);
00123   void Scale(double *p1, double *p2, int X, int Y);
00124 
00125   //virtual void SizeHandles();
00126   void CreateDefaultProperties();
00127 
00128   //BTX - manage the state of the widget
00129   int myState;
00130   enum WidgetState
00131   {
00132     Start=0,
00133     Moving,
00134     Scaling,
00135     Positioning,
00136     Outside
00137   };
00138   //ETX
00139   // the sphere
00140   vtkActor       *mySphereActor;
00141   vtkPolyDataMapper *mySphereMapper;
00142   vtkSphereSource   *mySphereSource;
00143   //
00144   // the Picker
00145   vtkCellPicker *myPicker;
00146   // Properties used to control the appearance of selected objects and
00147   // the manipulator in general.
00148   vtkProperty *mySphereProperty;
00149   vtkProperty *mySelectedSphereProperty;
00150   vtkFloatingPointType myRmin;
00151   vtkSphere *mySphere;
00152   vtkImplicitSum* myImplicitSum;
00153   vtkFloatingPointType myRatio;
00154 private:
00155   VISU_SphereWidget(const VISU_SphereWidget&);  //Not implemented
00156   void operator=(const VISU_SphereWidget&);  //Not implemented
00157 };
00158 
00159 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS