Salome HOME
4c8e00c45a9b831a35ad48197de9dd3d5300b80c
[modules/visu.git] / src / PIPELINE / VISU_WidgetCtrl.hxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  SALOME VTKViewer : build VTK viewer into Salome desktop
24 //  File   : VISU_WidgetCtrl.hxx
25 //  Author : Peter KURNEV
26 //  Module : SALOME
27 //  $Header$
28 //
29 #ifndef __VISU_WidgetCtrl_hxx
30 #define __VISU_WidgetCtrl_hxx
31
32 #include "VISUPipeline.hxx"
33 #include <vtkImplicitFunction.h>
34
35 #include "VTKViewer.h"
36
37 class vtkImplicitFunction;
38 class vtkObject;
39 class vtkRenderWindowInteractor;
40 class vtkCommand;
41 class vtkCallbackCommand;
42
43 class VISU_PlanesWidget;
44 class VISU_SphereWidget;
45 class VISU_ImplicitFunctionWidget;
46
47 class VISU_PIPELINE_EXPORT VISU_WidgetCtrl : public vtkImplicitFunction
48 {
49 public:
50   static VISU_WidgetCtrl *New();
51   vtkTypeRevisionMacro(VISU_WidgetCtrl,vtkObject);
52
53   vtkImplicitFunction* ImplicitFunction();
54
55   virtual
56   vtkFloatingPointType  
57   EvaluateFunction(vtkFloatingPointType theX[3]);
58
59   virtual
60   void  
61   EvaluateGradient(vtkFloatingPointType theX[3], 
62                    vtkFloatingPointType theG[3]);
63
64   virtual
65   unsigned long
66   GetMTime();
67
68   void PlaceWidget(vtkFloatingPointType theBounds[6]);
69   void SetEnabled(int theFlag);
70   int  GetEnabled();
71   void On() {SetEnabled(1);}
72   void Off(){SetEnabled(0);}
73   
74   void SetInteractor(vtkRenderWindowInteractor* theRWI);
75   vtkRenderWindowInteractor* GetInteractor();
76   //
77   void  
78   SetPlaceFactor(vtkFloatingPointType theFactor);
79
80   vtkFloatingPointType
81   GetPlaceFactor();
82   //
83   void SetActiveIndex(const int theFlag);
84   int  GetActiveIndex()const;
85   bool HasActiveIndex()const;
86   bool IsPlanesActive()const;
87   bool IsSphereActive()const;
88
89   
90   VISU_ImplicitFunctionWidget* GetActiveWidget();
91   VISU_ImplicitFunctionWidget* GetWidget(const int);
92
93   int GetNbWidgets()const;
94   int GetDisableAll()const;
95   
96   //
97   VISU_PlanesWidget * GetPlanesWidget();
98   VISU_SphereWidget * GetSphereWidget();
99   //
100   static void ProcessEvents(vtkObject* theObject, 
101                             unsigned long theEvent,
102                             void* theClientData, 
103                             void* theCalldata);
104   //
105 protected:
106   VISU_WidgetCtrl();
107   ~VISU_WidgetCtrl();
108
109 protected:
110   int myNbWidgets;
111   int myActiveIndex;
112   int myCounter;
113   int myDisableAll;
114   vtkFloatingPointType myPriority;
115   VISU_ImplicitFunctionWidget *myWidgets[2];
116   VISU_ImplicitFunctionWidget *myDummyWidget;
117   VISU_PlanesWidget *myPlanesWidget;
118   VISU_SphereWidget *mySphereWidget;
119   vtkCallbackCommand *myEventCallbackCommand;
120
121 private:
122   VISU_WidgetCtrl(const VISU_WidgetCtrl&);  //Not implemented
123   void operator=(const VISU_WidgetCtrl&);   //Not implemented
124 };
125
126 #endif