Salome HOME
cbfec5a179a87b0efb56991d251536d5ef204b10
[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   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteOpacity.
215   void
216   SetOpacity(vtkFloatingPointType theOpacity);
217
218   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteOpacity, vtkFloatingPointType).
219   vtkFloatingPointType
220   GetOpacity();
221
222   //! Set resolution of the Geometrical Sphere.
223   void
224   SetResolution(int theResolution);
225
226   //! Get resolution of the Geometrical Sphere.
227   int
228   GetResolution();
229
230   //! Method for changing the Magnification parameter.
231   void
232   ChangeMagnification( bool up );
233
234   //! Get the maximum size of Point Sprites in the presentation.
235   vtkFloatingPointType
236   GetMaxPointSize();
237
238   //! Get point size by element's Id.
239   vtkFloatingPointType
240   GetPointSize(vtkIdType theID);
241
242   //! Get point size by element's Id using the specified scalar array.
243   vtkFloatingPointType
244   GetPointSize(vtkIdType theID, vtkDataArray* theScalarArray);
245
246   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkSetMacro(AverageCellSize, vtkFloatingPointType).
247   void
248   SetAverageCellSize(vtkFloatingPointType AverageCellSize);
249
250   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(AverageCellSize, vtkFloatingPointType).
251   vtkFloatingPointType
252   GetAverageCellSize();
253
254   //! Set image data for the Point Sprite texture.
255   void
256   SetImageData(vtkImageData* theImageData);
257
258   //! Make the image data for Point Sprite texture.
259   /*!
260    * First parameter - texture for shape.
261    * Second parameter - texture for alpha mask.
262    */
263   static
264   vtkSmartPointer<vtkImageData>
265   MakeTexture( const char* theMainTexture,
266                const char* theAlphaTexture );
267
268 public:
269   //----------------------------------------------------------------------------
270   virtual 
271   void
272   SetIsDeformed( bool theIsDeformed );
273
274   virtual
275   bool
276   GetIsDeformed();
277
278   virtual
279   void
280   SetScale( vtkFloatingPointType theScale );
281
282   virtual
283   vtkFloatingPointType 
284   GetScale();
285
286   virtual
287   void
288   SetMapScale( vtkFloatingPointType theMapScale = 1.0 );
289
290 public:
291
292   virtual  
293   void  
294   SetSourceGeometry();
295
296   virtual
297   int
298   AddGeometry(vtkDataSet* theGeometry, const VISU::TName& theGeomName);
299
300   virtual
301   vtkDataSet*
302   GetGeometry(int theGeomNumber, VISU::TName& theGeomName);
303
304   virtual
305   int
306   GetNumberOfGeometry();
307
308   virtual
309   bool 
310   IsExternalGeometryUsed();
311
312   virtual
313   void
314   ClearGeometry();
315
316   virtual
317   void
318   GetSourceRange(vtkFloatingPointType theRange[2]);
319
320   virtual 
321   vtkPointSet* 
322   GetMergedInput();
323
324 protected:
325   //----------------------------------------------------------------------------
326   VISU_GaussPointsPL();
327
328   virtual
329   ~VISU_GaussPointsPL();
330
331   virtual
332   void
333   OnCreateMapperHolder();
334
335   virtual
336   void
337   Build();
338
339   virtual
340   vtkDataSet* 
341   InsertCustomPL();
342
343   virtual
344   void
345   DoShallowCopy(VISU_PipeLine *thePipeLine,
346                 bool theIsCopyInput);
347
348 private:
349   //----------------------------------------------------------------------------
350   vtkFloatingPointType myScaleFactor;
351   vtkWarpVector *myWarpVector;
352   std::vector<vtkPassThroughFilter*> myPassFilter;
353   vtkSmartPointer<VISU_PointSpriteMapperHolder> myPointSpriteMapperHolder;
354   
355   vtkGlyph3D* myGlyph;
356   vtkSphereSource* mySphereSource;
357
358   vtkFloatingPointType myMagnificationIncrement;
359
360   int myPrimitiveType;
361
362   vtkSmartPointer<VISU_AppendFilter>      myAppendFilter;
363   vtkSmartPointer<VISU_GaussMergeFilter>  myMergeFilter;
364
365 private:
366   VISU_GaussPointsPL(const VISU_GaussPointsPL&);  // Not implemented.
367   void operator=(const VISU_GaussPointsPL&);  // Not implemented.
368 };
369   
370 #endif