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