Salome HOME
Issue 0019818: EDF 703 SMESH VISU : Display Mesh Groups names in viewer (as a caption)
[modules/visu.git] / src / PIPELINE / VISU_GaussPointsPL.hxx
1 //  Copyright (C) 2007-2008  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 //  VISU OBJECT : interactive object for VISU entities implementation
23 // File:    VISU_GaussPointsPL.hxx
24 // Author:  
25 // Module : VISU
26 //
27 #ifndef VISU_GaussPointsPL_HeaderFile
28 #define VISU_GaussPointsPL_HeaderFile
29
30 #include "VISUPipeline.hxx"
31 #include "VISU_MergedPL.hxx"
32 #include "VISU_ColoredPL.hxx"
33
34 #include <vector>
35
36 class VISU_OpenGLPointSpriteMapper;
37 class VISU_PointSpriteMapperHolder;
38
39 class vtkGeometryFilter;
40 class vtkGlyph3D;
41 class vtkSphereSource;
42 class vtkDataArray;
43 class vtkImageData;
44 class vtkPointSet;
45 class vtkPassThroughFilter;
46 class vtkDataSet;
47
48 class vtkWarpVector;
49 class SALOME_Transform;
50
51 class VISU_AppendFilter;
52 class VISU_GaussMergeFilter;
53
54 //----------------------------------------------------------------------------
55 //! Pipeline for the Gauss Points presentation.
56 /*!
57  * This class uses the special mapper (VISU_OpenGLPointSpriteMapper)
58  * for rendering the Gauss Points as Point Sprites.
59  */
60 class VISU_PIPELINE_EXPORT VISU_GaussPointsPL : public VISU_MergedPL,
61                                                 public VISU_ColoredPL
62 {
63 public:
64   //----------------------------------------------------------------------------
65   vtkTypeMacro(VISU_GaussPointsPL, VISU_ColoredPL);
66
67   static 
68   VISU_GaussPointsPL* 
69   New();
70   
71   virtual
72   unsigned long int 
73   GetMTime();
74
75   //----------------------------------------------------------------------------
76   void 
77   SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper);
78
79   const VISU::PGaussPtsIDMapper&  
80   GetGaussPtsIDMapper();
81
82   VISU_PointSpriteMapperHolder*
83   GetPointSpriteMapperHolder();
84
85   //! Get the internal #VISU_OpenGLPointSpriteMapper.
86   VISU_OpenGLPointSpriteMapper*
87   GetPointSpriteMapper();
88
89   vtkDataSet*  
90   GetParentMesh();
91
92   //! Get an intermediate dataset that can be picked  
93   vtkPolyData*
94   GetPickableDataSet();
95
96   //----------------------------------------------------------------------------
97   //! Redefined method for initialization of the pipeline.
98   virtual
99   void
100   Init();
101
102   //! Redefined method for updating the pipeline.
103   virtual
104   void
105   Update();
106
107   //! Gets memory size used by the instance (bytes).
108   virtual
109   unsigned long int
110   GetMemorySize();
111
112   //----------------------------------------------------------------------------
113   //! Update glyph.
114   void
115   UpdateGlyph();
116
117   virtual 
118   VISU::TGaussPointID 
119   GetObjID(vtkIdType theID);
120
121   //! Set the Bicolor mode.
122   /*!
123    * When the Bicolor parameter is set to true, scalar bars are
124    * drawing with two colors : red color correspoonds to positive
125    * scalar values, blue color - to negative values.
126    */
127   void
128   SetBicolor(bool theBicolor);
129
130   //! Get the Bicolor mode.
131   bool
132   GetBicolor();
133
134   //! Set the Multicolored mode.
135   /*!
136    * This parameter is using to switch between Results and Geometry
137    * modes. Multiple colors are using when the presentation is
138    * drawing in the Results mode, one color - in the Geometry mode.
139    */
140   void
141   SetIsColored(bool theIsColored);
142
143   bool 
144   GetIsColored();
145
146   //! Set type of the primitives.
147   void
148   SetPrimitiveType(int thePrimitiveType);
149
150   //! Get type of the primitives.
151   int
152   GetPrimitiveType();
153
154   //! Get the maximum Point Sprite size, which is supported by hardware.
155   vtkFloatingPointType 
156   GetMaximumSupportedSize();
157
158   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteClamp.
159   void
160   SetClamp(vtkFloatingPointType theClamp);
161
162   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteClamp, vtkFloatingPointType).
163   vtkFloatingPointType
164   GetClamp();
165
166   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteSize.
167   void
168   SetSize(vtkFloatingPointType theSize);
169
170   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteSize, vtkFloatingPointType).
171   vtkFloatingPointType 
172   GetSize();
173
174   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize.
175   void
176   SetMinSize(vtkFloatingPointType theMinSize);
177
178   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMinSize, vtkFloatingPointType).
179   vtkFloatingPointType 
180   GetMinSize();
181
182   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize.
183   void
184   SetMaxSize(vtkFloatingPointType theMaxSize);
185
186   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMaxSize, vtkFloatingPointType).
187   vtkFloatingPointType 
188   GetMaxSize();
189
190   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMagnification.
191   void
192   SetMagnification(vtkFloatingPointType theMagnification);
193
194   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMagnification, vtkFloatingPointType).
195   vtkFloatingPointType
196   GetMagnification();
197
198   //! Set the increment of changing Magnification parameter.
199   void
200   SetMagnificationIncrement(vtkFloatingPointType theIncrement);
201
202   //! Get the increment of changing Magnification parameter.
203   vtkFloatingPointType
204   GetMagnificationIncrement() { return myMagnificationIncrement; }
205
206   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteAlphaThreshold.
207   void
208   SetAlphaThreshold(vtkFloatingPointType theAlphaThreshold);
209
210   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteAlphaThreshold, vtkFloatingPointType).
211   vtkFloatingPointType
212   GetAlphaThreshold();
213
214   //! Set resolution of the Geometrical Sphere.
215   void
216   SetResolution(int theResolution);
217
218   //! Get resolution of the Geometrical Sphere.
219   int
220   GetResolution();
221
222   //! Method for changing the Magnification parameter.
223   void
224   ChangeMagnification( bool up );
225
226   //! Get the maximum size of Point Sprites in the presentation.
227   vtkFloatingPointType
228   GetMaxPointSize();
229
230   //! Get point size by element's Id.
231   vtkFloatingPointType
232   GetPointSize(vtkIdType theID);
233
234   //! Get point size by element's Id using the specified scalar array.
235   vtkFloatingPointType
236   GetPointSize(vtkIdType theID, vtkDataArray* theScalarArray);
237
238   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkSetMacro(AverageCellSize, vtkFloatingPointType).
239   void
240   SetAverageCellSize(vtkFloatingPointType AverageCellSize);
241
242   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(AverageCellSize, vtkFloatingPointType).
243   vtkFloatingPointType
244   GetAverageCellSize();
245
246   //! Set image data for the Point Sprite texture.
247   void
248   SetImageData(vtkImageData* theImageData);
249
250   //! Make the image data for Point Sprite texture.
251   /*!
252    * First parameter - texture for shape.
253    * Second parameter - texture for alpha mask.
254    */
255   static
256   vtkSmartPointer<vtkImageData>
257   MakeTexture( const char* theMainTexture,
258                const char* theAlphaTexture );
259
260 public:
261   //----------------------------------------------------------------------------
262   virtual 
263   void
264   SetIsDeformed( bool theIsDeformed );
265
266   virtual
267   bool
268   GetIsDeformed();
269
270   virtual
271   void
272   SetScale( vtkFloatingPointType theScale );
273
274   virtual
275   vtkFloatingPointType 
276   GetScale();
277
278   virtual
279   void
280   SetMapScale( vtkFloatingPointType theMapScale = 1.0 );
281
282 public:
283
284   virtual  
285   void  
286   SetSourceGeometry();
287
288   virtual
289   int
290   AddGeometry(vtkDataSet* theGeometry);
291
292   virtual
293   vtkDataSet*
294   GetGeometry(int theGeomNumber);
295
296   virtual
297   int
298   GetNumberOfGeometry();
299
300   virtual
301   bool 
302   IsExternalGeometryUsed();
303
304   virtual
305   void
306   ClearGeometry();
307
308   virtual 
309   vtkPointSet* 
310   GetMergedInput();
311
312 protected:
313   //----------------------------------------------------------------------------
314   VISU_GaussPointsPL();
315
316   virtual
317   ~VISU_GaussPointsPL();
318
319   virtual
320   void
321   OnCreateMapperHolder();
322
323   virtual
324   void
325   Build();
326
327   virtual
328   vtkDataSet* 
329   InsertCustomPL();
330
331   virtual
332   void
333   DoShallowCopy(VISU_PipeLine *thePipeLine,
334                 bool theIsCopyInput);
335
336 private:
337   //----------------------------------------------------------------------------
338   vtkFloatingPointType myScaleFactor;
339   vtkWarpVector *myWarpVector;
340   std::vector<vtkPassThroughFilter*> myPassFilter;
341   vtkSmartPointer<VISU_PointSpriteMapperHolder> myPointSpriteMapperHolder;
342   
343   vtkGlyph3D* myGlyph;
344   vtkSphereSource* mySphereSource;
345
346   vtkFloatingPointType myMagnificationIncrement;
347
348   int myPrimitiveType;
349
350   vtkSmartPointer<VISU_AppendFilter>      myAppendFilter;
351   vtkSmartPointer<VISU_GaussMergeFilter>  myMergeFilter;
352
353 private:
354   VISU_GaussPointsPL(const VISU_GaussPointsPL&);  // Not implemented.
355   void operator=(const VISU_GaussPointsPL&);  // Not implemented.
356 };
357   
358 #endif