Salome HOME
e8b47fc437d2af169977bddf74ec0257f283b70c
[modules/visu.git] / src / PIPELINE / VISU_GaussPointsPL.hxx
1 //  VISU OBJECT : interactive object for VISU entities implementation
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:    VISU_GaussPointsPL.hxx
25 // Author:  
26 // Module : VISU
27
28 #ifndef VISU_GaussPointsPL_HeaderFile
29 #define VISU_GaussPointsPL_HeaderFile
30
31 #include "VISU_ScalarMapPL.hxx"
32 #include "VISU_Convertor.hxx"
33
34 #include <vector>
35
36 class VTKViewer_PassThroughFilter;
37 class VISU_OpenGLPointSpriteMapper;
38
39 class vtkGeometryFilter;
40 class vtkGlyph3D;
41 class vtkSphereSource;
42 class vtkDataArray;
43 class vtkImageData;
44 class vtkPointSet;
45
46 class vtkCellDataToPointData;
47 class vtkWarpVector;
48 class SALOME_Transform;
49
50 //! Pipeline for the Gauss Points presentation.
51 /*!
52  * This class uses the special mapper (VISU_OpenGLPointSpriteMapper)
53  * for rendering the Gauss Points as Point Sprites.
54  */
55 class VISU_GaussPointsPL : public VISU_ScalarMapPL
56 {
57 protected:
58   VISU_GaussPointsPL();
59
60   virtual
61   ~VISU_GaussPointsPL();
62
63 public:
64   vtkTypeMacro(VISU_GaussPointsPL,VISU_ScalarMapPL);
65
66   static 
67   VISU_GaussPointsPL* New();
68   
69   virtual
70   void
71   ShallowCopy(VISU_PipeLine *thePipeLine);
72
73   //! Get the native mapper.
74   virtual
75   TMapper* 
76   GetMapper();
77
78   //! Get the internal #VISU_OpenGLPointSpriteMapper.
79   VISU_OpenGLPointSpriteMapper*
80   GetPSMapper();
81
82   //! Get an intermediate dataset that can be picked  
83   vtkDataSet*
84   GetPickableDataSet();
85
86   //! Redefined method for initialization of the pipeline.
87   virtual
88   void
89   Init();
90
91   //! Redefined method for building the pipeline.
92   virtual
93   void
94   Build();
95
96   //! Redefined method for updating the pipeline.
97   virtual
98   void
99   Update();
100
101   //! Update glyph.
102   void
103   UpdateGlyph();
104
105   virtual 
106   VISU::TGaussPointID 
107   GetObjID(vtkIdType theID) const;
108
109   virtual
110   vtkFloatingPointType* 
111   GetNodeCoord(vtkIdType theObjID);
112
113   void 
114   SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper);
115
116   const VISU::PGaussPtsIDMapper&  
117   GetGaussPtsIDMapper() const;
118
119   VISU::TVTKOutput*  
120   GetParentMesh() const;
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   //! Set type of the primitives.
145   void
146   SetPrimitiveType(int thePrimitiveType);
147
148   //! Get type of the primitives.
149   int
150   GetPrimitiveType();
151
152   //! Get the maximum Point Sprite size, which is supported by hardware.
153   vtkFloatingPointType 
154   GetMaximumSupportedSize();
155
156   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteClamp.
157   void
158   SetClamp(vtkFloatingPointType theClamp);
159
160   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteClamp, vtkFloatingPointType).
161   vtkFloatingPointType
162   GetClamp();
163
164   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteSize.
165   void
166   SetSize(vtkFloatingPointType theSize);
167
168   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteSize, vtkFloatingPointType).
169   vtkFloatingPointType 
170   GetSize();
171
172   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize.
173   void
174   SetMinSize(vtkFloatingPointType theMinSize);
175
176   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMinSize, vtkFloatingPointType).
177   vtkFloatingPointType 
178   GetMinSize();
179
180   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMinSize.
181   void
182   SetMaxSize(vtkFloatingPointType theMaxSize);
183
184   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMaxSize, vtkFloatingPointType).
185   vtkFloatingPointType 
186   GetMaxSize();
187
188   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteMagnification.
189   void
190   SetMagnification(vtkFloatingPointType theMagnification);
191
192   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteMagnification, vtkFloatingPointType).
193   vtkFloatingPointType
194   GetMagnification();
195
196   //! Set the increment of changing Magnification parameter.
197   void
198   SetMagnificationIncrement(vtkFloatingPointType theIncrement);
199
200   //! Get the increment of changing Magnification parameter.
201   vtkFloatingPointType
202   GetMagnificationIncrement() { return myMagnificationIncrement; }
203
204   //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteAlphaThreshold.
205   void
206   SetAlphaThreshold(vtkFloatingPointType theAlphaThreshold);
207
208   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteAlphaThreshold, vtkFloatingPointType).
209   vtkFloatingPointType
210   GetAlphaThreshold();
211
212   //! Set resolution of the Geometrical Sphere.
213   void
214   SetResolution(int theResolution);
215
216   //! Get resolution of the Geometrical Sphere.
217   int
218   GetResolution() { return myResolution; }
219
220   //! Method for changing the Magnification parameter.
221   void
222   ChangeMagnification( bool up );
223
224   //! Get the maximum size of Point Sprites in the presentation.
225   vtkFloatingPointType
226   GetMaxPointSize();
227
228   //! Get point size by element's Id.
229   vtkFloatingPointType
230   GetPointSize(vtkIdType theID);
231
232   //! Get point size by element's Id using the specified scalar array.
233   vtkFloatingPointType
234   GetPointSize(vtkIdType theID, vtkDataArray* theScalarArray);
235
236   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkSetMacro(AverageCellSize, vtkFloatingPointType).
237   void
238   SetAverageCellSize(vtkFloatingPointType AverageCellSize);
239
240   //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(AverageCellSize, vtkFloatingPointType).
241   vtkFloatingPointType
242   GetAverageCellSize();
243
244   //! Set image data for the Point Sprite texture.
245   void
246   SetImageData(vtkImageData* theImageData);
247
248   //! Make the image data for Point Sprite texture.
249   /*!
250    * First parameter - texture for shape.
251    * Second parameter - texture for alpha mask.
252    */
253   static
254   vtkSmartPointer<vtkImageData>
255   MakeTexture( const char* theMainTexture,
256                const char* theAlphaTexture );
257
258 public:
259   virtual void  SetIsDeformed( bool theIsDeformed );
260   virtual bool  GetIsDeformed() const;
261
262   virtual void  SetScale( vtkFloatingPointType theScale );
263   virtual vtkFloatingPointType GetScale();
264   virtual void  SetMapScale( vtkFloatingPointType theMapScale = 1.0 );
265
266 protected:
267   bool myIsDeformed;
268   vtkFloatingPointType myScaleFactor;
269   vtkWarpVector *myWarpVector;
270   vtkCellDataToPointData* myCellDataToPointData;
271   std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
272   
273   vtkGlyph3D* myGlyph;
274   vtkSphereSource* mySphereSource;
275   int myResolution;
276
277 protected:
278   VISU_OpenGLPointSpriteMapper* myPSMapper;
279   VISU::PGaussPtsIDMapper myGaussPtsIDMapper;
280
281   vtkGeometryFilter* myGeomFilter;
282
283   vtkDataArray *myScalarArray;
284   vtkFloatingPointType mySourceScalarRange[2];
285   vtkFloatingPointType myDeltaScalarRange;
286
287   int   myPrimitiveType;
288   vtkFloatingPointType myMagnificationIncrement;
289 };
290   
291 #endif