Salome HOME
Merge from OCC_development_generic_2006
[modules/visu.git] / src / VVTK / VVTK_Renderer.h
1 //  SALOME VTKViewer : build VTK viewer into Salome desktop
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : 
25 //  Author : 
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef VVTK_Renderer_h
30 #define VVTK_Renderer_h
31
32 #include "VVTK.h"
33
34 #include "SVTK_Renderer.h"
35
36 class VISU_WidgetCtrl;
37 class VISU_InsideCursorSettings;
38 class VISU_OutsideCursorSettings;
39 class VISU_PickingSettings;
40 class VISU_FPSActor;
41
42 class vtkPointPicker;
43 class vtkImplicitFunction;
44
45 //----------------------------------------------------------------------------
46 //! To customize SVTK_Renderer according to VVTK functionality
47 class VVTK_EXPORT VVTK_Renderer : public SVTK_Renderer
48 {
49  public:
50   vtkTypeMacro(VVTK_Renderer,SVTK_Renderer);
51   static VVTK_Renderer* New();
52
53   //! Reimplement SVTK_Renderer::AddActor
54   /*!
55     Perform an additional action - apply picking settings on the published VISU_GaussPtsAct actors
56   */
57   virtual
58   void 
59   AddActor(VTKViewer_Actor* theActor);
60
61   //! Reimplement SVTK_Renderer::RemoveActor (remove additional settings)
62   virtual
63   void 
64   RemoveActor(VTKViewer_Actor* theActor);
65
66   //! To set VISU_PickingSettings to share them among all VISU_GaussPtsAct actors published into the view 
67   void
68   SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings);
69
70   void
71   SetPickingSettings(VISU_PickingSettings* thePickingSettings);
72
73  protected:
74   VVTK_Renderer();
75   ~VVTK_Renderer();
76
77   VISU_PickingSettings* myPickingSettings; //! Keeps reference of the VISU_PickingSettings
78   VISU_InsideCursorSettings* myInsideCursorSettings; //! Keeps reference of the VISU_InsideCursorSettings
79   vtkSmartPointer<VISU_FPSActor> myFPSActor; //!< To show FPS of the rendering at run-time
80
81   vtkSmartPointer<vtkPointPicker> myGaussPointPicker;
82   vtkSmartPointer<vtkProperty>    myGaussPreHighlightProperty;
83   vtkSmartPointer<vtkProperty>    myGaussHighlightProperty;
84 };
85
86
87 //----------------------------------------------------------------------------
88 //! To extend VVTK_Renderer to implement base view functionality
89 class VVTK_EXPORT VVTK_Renderer1 : public VVTK_Renderer
90 {
91  public:
92   vtkTypeMacro(VVTK_Renderer1,VVTK_Renderer);
93   static VVTK_Renderer1* New();
94
95   //! Reimplement SVTK_Renderer::Initialize
96   virtual
97   void 
98   Initialize(vtkRenderWindowInteractor* theInteractor,
99              SVTK_Selector* theSelector);
100
101   //! Reimplement VVTK_Renderer::AddActor to apply to the actor additional settings
102   virtual
103   void 
104   AddActor(VTKViewer_Actor* theActor);
105
106   //! Reimplement VVTK_Renderer::RemoveActor
107   virtual
108   void 
109   RemoveActor(VTKViewer_Actor* theActor);
110
111   //! To set VISU_PickingSettings to share them among all VISU_GaussPtsAct1 actors published into the view 
112   void
113   SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
114
115   VISU_WidgetCtrl*  GetWidgetCtrl();
116
117  protected:
118   VVTK_Renderer1();
119   ~VVTK_Renderer1();
120
121   //! Reimplement VVTK_Renderer::OnAdjustActors
122   virtual
123   bool
124   OnAdjustActors();
125
126   void AdjustWidgetCtrl();
127
128   vtkSmartPointer<VISU_WidgetCtrl> myWidgetCtrl;
129   VISU_OutsideCursorSettings* myOutsideCursorSettings;
130   vtkSmartPointer<VISU_FPSActor> myTextActor;
131 };
132
133
134 //----------------------------------------------------------------------------
135 class VVTK_EXPORT VVTK_Renderer2 : public VVTK_Renderer
136 {
137  public:
138   vtkTypeMacro(VVTK_Renderer2,VVTK_Renderer);
139   static VVTK_Renderer2* New();
140
141   //! Reimplement VVTK_Renderer::AddActor to apply to the actor additional settings
142   virtual
143   void 
144   AddActor(VTKViewer_Actor* theActor);
145
146   //! Reimplement VVTK_Renderer::RemoveActor
147   virtual
148   void 
149   RemoveActor(VTKViewer_Actor* theActor);
150
151   void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
152
153   //! To handle vtkCommand::EndInteractionEvent to redraw the view
154   void
155   OnEndInteractionEvent();
156
157  protected:
158   VVTK_Renderer2();
159   ~VVTK_Renderer2();
160
161   //! Main process VTK event method
162   static
163   void
164   ProcessEvents(vtkObject* theObject, 
165                 unsigned long theEvent,
166                 void* theClientData, 
167                 void* theCallData);
168
169   //! Used to process VTK events
170   vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
171
172   //! Priority at which events are processed
173   float myPriority;
174
175   VISU_WidgetCtrl* myWidgetCtrl;
176 };
177
178
179 #endif