]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_PrsObject_i.hh
Salome HOME
NRI : First integration.
[modules/visu.git] / src / VISU_I / VISU_PrsObject_i.hh
1 // File:        VISU_PrsObject_i.hxx
2 // Created:     Fri Jan 17 09:26:33 2003
3 // Author:      Alexey PETROV
4 //              <apo@ivanox.nnov.matra-dtv.fr>
5
6
7 #ifndef VISU_PrsObject_i_HeaderFile
8 #define VISU_PrsObject_i_HeaderFile
9
10 #include "VISU_Result_i.hh"
11 //#include "VISU_Convertor.hxx"
12 #include "Handle_SALOME_InteractiveObject.hxx"
13
14 class VISU_Extractor;
15 class VISU_FieldTransform;
16 class VISU_Actor;
17
18 class vtkDataSetMapper;
19 class vtkDataSet;
20 class vtkProperty;
21
22 class vtkWarpVector;
23 class vtkContourFilter;
24 class vtkAppendPolyData;
25
26 class vtkGlyph3D;
27 class vtkHedgeHog;
28 class vtkPolyDataSource;
29 class vtkStreamLine;
30
31
32 namespace VISU{
33   struct TField;
34   //==============================================================================
35   class PrsObject_i : public virtual POA_VISU::PrsObject,
36                       public virtual Storable
37   {
38     PrsObject_i(const PrsObject_i&);
39
40   public:
41     PrsObject_i(SALOMEDS::Study_ptr theStudy) : 
42       myStudy(SALOMEDS::Study::_duplicate(theStudy)) {};
43     virtual ~PrsObject_i() {}
44
45   protected:
46     string myName;
47     SALOMEDS::Study_var myStudy;
48
49   public:
50     virtual const char* GetName() const { return myName.c_str();}
51     const SALOMEDS::Study_var& GetStudyDocument() const { return myStudy;}
52     QString GetEntry();
53   };
54
55
56   //==============================================================================
57   class Prs3d_i : public virtual PrsObject_i
58   {
59     Prs3d_i();
60     Prs3d_i(const Prs3d_i&);
61   public:
62     Prs3d_i(Result_i* theResult);
63     virtual void SameAs(const Prs3d_i* theOrigin);
64     virtual ~Prs3d_i();
65
66     typedef vtkDataSetMapper MapperType;
67     typedef vtkDataSet DataType;
68     
69     virtual const float* GetColor() const { return myColorRGB;}
70     virtual void SetColor(const float* theRGB){
71       myColor.R = myColorRGB[0] = theRGB[0]; 
72       myColor.G = myColorRGB[1] = theRGB[1]; 
73       myColor.B = myColorRGB[2] = theRGB[2];
74     }
75
76
77   protected:
78     Result_i* myResult;
79     MapperType *myMapper;
80     float myBounds[6];
81     float myColorRGB[3];
82     struct SALOMEDS::Color myColor;
83
84     bool myAddToStudy;
85
86   public:
87     virtual void Update();
88     virtual const char* GetComment() const = 0;
89     virtual QString GenerateName() = 0;
90     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
91       throw(std::logic_error&);
92     virtual void ToStream(ostrstream& theStr);
93     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
94     MapperType* GetMapper() const { return myMapper;}
95     Result_i* GetResult() const { return myResult; }
96   };
97
98
99   //==============================================================================
100   class Mesh_i : public virtual POA_VISU::Mesh,
101                  public virtual Prs3d_i
102   {
103     static int myNbPresent;
104     Mesh_i();
105     Mesh_i(const Mesh_i&);
106   public:
107     Mesh_i(Result_i* theResult);
108     virtual void SameAs(const Mesh_i* theOrigin);
109     virtual ~Mesh_i();
110     virtual VISU::VISUType GetType() { return VISU::TMESH;};
111
112     virtual void SetCellColor(const SALOMEDS::Color& theColor) { myCellColor = theColor;}
113     virtual SALOMEDS::Color GetCellColor() { return myCellColor;}
114
115     virtual void SetNodeColor(const SALOMEDS::Color& theColor) { myNodeColor = theColor;}
116     virtual SALOMEDS::Color GetNodeColor() { return myNodeColor;}
117
118     virtual void SetLinkColor(const SALOMEDS::Color& theColor) { myLinkColor = theColor;}
119     virtual SALOMEDS::Color GetLinkColor() { return myLinkColor;}
120
121     virtual void SetPresentationType(VISU::PresentationType theType) { myPresentType = theType;}
122     virtual PresentationType GetPresentationType() { return myPresentType;}
123
124     typedef VISU::Mesh InterfaceType;
125     typedef vtkUnstructuredGridReader InputType;
126
127   protected:
128     Storable* Build(int theRestoring);
129
130     InputType *myInput;
131     VISU::VISUType myType;
132     string myMeshName;
133     int myEntity;
134     string mySubMeshName;
135     struct SALOMEDS::Color myCellColor, myNodeColor, myLinkColor;
136     VISU::PresentationType myPresentType;
137
138   public:
139     virtual Storable* Create(const char* theMeshName, int theEntity);
140     virtual Storable* Create(const char* theMeshName, int theEntity, const char* theFamilyName);
141     virtual Storable* Create(const char* theMeshName, const char* theGroupName);
142     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
143       throw(std::logic_error&);
144     virtual void ToStream(ostrstream& theStr);
145     static const string myComment;
146     virtual const char* GetComment() const;
147     virtual QString GenerateName();
148     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
149     virtual InputType* GetInput() const { return myInput;}
150   };
151   Storable* MeshRestore(SALOMEDS::SObject_ptr theSObject, 
152                         const string& thePrefix, const Storable::TRestoringMap& theMap)
153     throw(std::logic_error&);
154
155
156   //==============================================================================
157   class ScalarMap_i : public virtual POA_VISU::ScalarMap,
158                       public virtual Prs3d_i
159   {
160     static int myNbPresent;
161     ScalarMap_i();
162     ScalarMap_i(const ScalarMap_i&);
163
164   public:
165     ScalarMap_i(Result_i* theResult, bool theAddToStudy = true);
166     virtual void SameAs(const ScalarMap_i* theOrigin);
167     virtual ~ScalarMap_i();
168
169     virtual VISU::VISUType GetType() { return VISU::TSCALARMAP;};
170
171     virtual void SetScalarMode(CORBA::Long theScalarMode);
172     virtual CORBA::Long GetScalarMode() { return myScalarMode;}
173
174     virtual void SetScaling(VISU::Scaling theScaling);
175     virtual VISU::Scaling GetScaling();
176
177     virtual void SetRange(CORBA::Double theMin, CORBA::Double theMax);
178     virtual CORBA::Double GetMin() { return myScalarRange[0];}  
179     virtual CORBA::Double GetMax() { return myScalarRange[1];}
180
181     virtual void SetOrientation(VISU::ScalarMap::Orientation theOrientation) { 
182       myOrientation = theOrientation;
183     }
184     virtual VISU::ScalarMap::Orientation GetOrientation() { return myOrientation;}
185
186     virtual void SetPosition(CORBA::Double X, CORBA::Double Y) { myPosition[0] = X; myPosition[1] = Y;}
187     virtual CORBA::Double GetPosX() { return myPosition[0];} 
188     virtual CORBA::Double GetPosY() { return myPosition[1];}
189       
190     virtual void SetSize(CORBA::Double theWidth, CORBA::Double theHeight) { 
191       myWidth = theWidth; myHeight = theHeight;
192     }
193     virtual CORBA::Double GetWidth() { return myWidth;}  
194     virtual CORBA::Double GetHeight() { return myHeight;}
195
196     virtual void SetNbColors(CORBA::Long theNbColors) { myNumberOfColors = theNbColors;}
197     virtual CORBA::Long GetNbColors() { return myNumberOfColors;}
198
199     virtual void SetLabels(CORBA::Long theNbLabels) { myNumberOfLabels = theNbLabels;}
200     virtual CORBA::Long GetLabels() { return myNumberOfLabels;}
201     
202     virtual void SetTitle(const char* theName) { myTitle = theName;}
203     virtual char* GetTitle() { return CORBA::string_dup(myTitle.c_str());}
204
205     virtual void CalculateRange();
206     virtual bool isRangeFixed() { return myIsFixedRange; }
207     
208     virtual double GetIteration() { return myIteration; }
209
210     typedef VISU::ScalarMap InterfaceType;
211     typedef VISU_Extractor InputType;
212
213   protected:
214     Storable* Build(int theRestoring);
215     virtual DataType* DoHook(int theRestoring);
216
217     InputType *myInput;
218     
219     string myMeshName;
220     int myEntity;
221     string myFieldName;
222     int myScalarMode;
223     double myIteration;
224     VISU_FieldTransform *myFieldTransform;
225     const TField* myField;
226     
227     float myScalarRange[2];
228     bool myIsFixedRange;
229     VISU::Scaling myScaling;
230
231     string myTitle;
232     VISU::ScalarMap::Orientation myOrientation;
233     int myNumberOfColors, myNumberOfLabels;
234     float myPosition[2], myWidth, myHeight;
235
236   public:
237     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
238                              const char* theFieldName, double theIteration);
239     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
240       throw(std::logic_error&);
241     static const string myComment;
242     virtual const char* GetComment() const;
243     virtual QString GenerateName();
244     virtual void ToStream(ostrstream& theStr);
245     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
246                           const char* theFieldName, double theIteration);
247     InputType* GetInput() { return myInput;}
248
249     virtual void Update();
250     const VISU::TField*  GetField() const { return myField;}
251     const string&  GetFieldName() const { return myFieldName;}
252     int GetScalarMode() const { return myScalarMode;}
253
254     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
255   };
256   Storable* ScalarMapRestore(SALOMEDS::SObject_ptr theSObject, 
257                              const string& thePrefix, const Storable::TRestoringMap& theMap)
258     throw(std::logic_error&);
259
260
261   //==============================================================================
262   class DeformedShape_i : public virtual POA_VISU::DeformedShape,
263                           public virtual ScalarMap_i
264   {
265     static int myNbPresent;
266     DeformedShape_i();
267     DeformedShape_i(const DeformedShape_i&);
268   public:
269     DeformedShape_i(Result_i* theResult, bool theAddToStudy = true);
270     virtual void SameAs(const DeformedShape_i* theOrigin);
271     virtual ~DeformedShape_i();
272
273     virtual VISU::VISUType GetType() { return VISU::TDEFORMEDSHAPE;};
274
275     virtual void SetScale(CORBA::Double theScale) { myFactor = theScale;}
276     virtual CORBA::Double GetScale() { return myFactor;}
277
278     typedef VISU::DeformedShape InterfaceType;
279
280     virtual bool isColored() { return myIsColored; }
281     virtual void setColored(bool theColor) 
282     { myIsColored = theColor; }
283
284   protected:
285     virtual DataType* DoHook(int theRestoring);
286     float myFactor;
287     bool myIsColored;
288     vtkWarpVector *myWarpVector;
289
290   public:
291     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
292                              const char* theFieldName, double theIteration);
293     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
294       throw(std::logic_error&);
295     static const string myComment;
296     virtual const char* GetComment() const;
297     virtual QString GenerateName();
298     virtual void Update();
299     virtual void ToStream(ostrstream& theStr);
300     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
301                           const char* theFieldName, double theIteration);
302     float ScaleFactor();
303
304     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
305   };
306   Storable* DeformedShapeRestore(SALOMEDS::SObject_ptr theSObject, 
307                                  const string& thePrefix, const Storable::TRestoringMap& theMap)
308     throw(std::logic_error&);
309
310
311
312
313   //==============================================================================
314   class CutPlanes_i : public virtual POA_VISU::CutPlanes,
315                       public virtual ScalarMap_i
316   {
317     static int myNbPresent;
318     CutPlanes_i();
319     CutPlanes_i(const CutPlanes_i&);
320   public:
321     CutPlanes_i(Result_i* theResult, bool theAddToStudy = true);
322     virtual void SameAs(const CutPlanes_i* theOrigin);
323     virtual ~CutPlanes_i();
324     virtual VISU::VISUType GetType() { return VISU::TCUTPLANES;};
325
326     virtual void SetOrientationType(VISU::CutPlanes::Orientation theOrient) { 
327       myBasePlane = theOrient;
328     }
329     virtual VISU::CutPlanes::Orientation GetOrientationType() { return myBasePlane;}
330
331     virtual void SetNbPlanes(CORBA::Long theNb) { myNbPlanes = theNb;}
332     virtual CORBA::Long GetNbPlanes() { return myNbPlanes;}
333     
334     virtual void SetRotateX(CORBA::Double theAngle);
335     virtual CORBA::Double GetRotateX();
336     virtual void SetRotateY(CORBA::Double theAngle);
337     virtual CORBA::Double GetRotateY();
338     
339     typedef VISU::CutPlanes InterfaceType;
340
341   protected:
342     virtual DataType* DoHook(int theRestoring);
343
344     float myRotation[3][3];
345     float myAng[3], myDir[3], myInvDir[3], myBoundPrj[3], myDBPrj;
346     vtkAppendPolyData *myAppendPolyData;
347     VISU::CutPlanes::Orientation myBasePlane;
348     int myNbPlanes;
349
350   public:
351     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
352                              const char* theFieldName, double theIteration);
353     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
354       throw(std::logic_error&);
355     static const string myComment;
356     virtual const char* GetComment() const;
357     virtual QString GenerateName();
358     virtual void Update();
359     virtual void ToStream(ostrstream& theStr);
360     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
361                           const char* theFieldName, double theIteration);
362     void SetPlane(int theId);
363
364     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
365   };
366   Storable* CutPlanesRestore(SALOMEDS::SObject_ptr theSObject, 
367                              const string& thePrefix, const Storable::TRestoringMap& theMap)
368     throw(std::logic_error&);
369
370
371
372   //==============================================================================
373   class IsoSurfaces_i : public virtual POA_VISU::IsoSurfaces,
374                         public virtual ScalarMap_i
375   {
376     static int myNbPresent;
377     IsoSurfaces_i();
378     IsoSurfaces_i(const IsoSurfaces_i&);
379   public:
380     IsoSurfaces_i(Result_i* theResult, bool theAddToStudy = true);
381     virtual void SameAs(const IsoSurfaces_i* theOrigin);
382     virtual ~IsoSurfaces_i();
383     virtual VISU::VISUType GetType() { return VISU::TISOSURFACE;};
384
385     virtual void SetNbSurfaces(CORBA::Long theNb) { myNbSurface = theNb;}
386     virtual CORBA::Long GetNbSurfaces() { return myNbSurface;}
387
388     virtual void SetRange(float theMin, float theMax)
389     { myRange[0] = theMin;  myRange[1] = theMax; }
390
391     virtual float GetRangeMin() { return myRange[0]; }
392     virtual float GetRangeMax() { return myRange[1]; }
393
394     typedef VISU::IsoSurfaces InterfaceType;
395
396   protected:
397     virtual DataType* DoHook(int theRestoring);
398
399     vtkContourFilter *myContourFilter;
400     int myNbSurface;
401     float myRange[2];
402
403   public:
404     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
405                              const char* theFieldName, double theIteration);
406     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
407       throw(std::logic_error&);
408     static const string myComment;
409     virtual const char* GetComment() const;
410     virtual QString GenerateName();
411     virtual void Update();
412     virtual void ToStream(ostrstream& theStr);
413     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
414                           const char* theFieldName, double theIteration);
415     vtkContourFilter* GetFilter() { return myContourFilter;}
416     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
417   };
418   Storable* IsoSurfacesRestore(SALOMEDS::SObject_ptr theSObject, 
419                                const string& thePrefix, const Storable::TRestoringMap& theMap)
420     throw(std::logic_error&);
421
422
423
424   //==============================================================================
425   class StreamLines_i : public virtual POA_VISU::StreamLines,
426                         public virtual DeformedShape_i
427   {
428     static int myNbPresent;
429     StreamLines_i();
430     StreamLines_i(const StreamLines_i&);
431   public:
432     StreamLines_i(Result_i* theResult, bool theAddToStudy = true);
433     virtual void SameAs(const StreamLines_i* theOriginal);
434     virtual ~StreamLines_i();
435
436     virtual VISU::VISUType GetType() { return VISU::TSTREAMLINES;}
437
438     typedef VISU::StreamLines InterfaceType;
439
440     virtual void SetDirection(VISU::StreamLines::Direction theDirection) 
441     { myDirection = theDirection; }
442     virtual VISU::StreamLines::Direction GetDirection() { return myDirection;}
443
444     virtual void SetStepLength(float theStep) { myStepLength = theStep; }
445     virtual float GetStepLength() { return myStepLength; }
446
447     virtual void SetPropagationTime(float theTime) { myPropagationTime = theTime; }
448     virtual float GetPropagationTime() { return myPropagationTime; }
449
450     virtual void SetIntegrationStep(float theStep) { myIntegrationStep = theStep; }
451     virtual float GetIntegrationStep() { return myIntegrationStep; }
452
453   protected:
454     virtual DataType* DoHook(int theRestoring);
455     vtkStreamLine* myStream;
456
457     VISU::StreamLines::Direction myDirection;
458     float myStepLength;
459     float myIntegrationStep;
460     float myPropagationTime;
461
462   public:
463     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
464                              const char* theFieldName, double theIteration);
465     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
466       throw(std::logic_error&);
467     static const string myComment;
468     virtual const char* GetComment() const;
469     virtual QString GenerateName();
470     virtual void Update();
471     virtual void ToStream(ostrstream& theStr);
472     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
473                           const char* theFieldName, double theIteration);
474     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
475   };
476   Storable* StreamLinesRestore(SALOMEDS::SObject_ptr theSObject, 
477                                const string& thePrefix, const Storable::TRestoringMap& theMap)
478     throw(std::logic_error&);
479
480
481   //==============================================================================
482   class Vectors_i : public virtual POA_VISU::Vectors,
483                     public virtual DeformedShape_i
484   {
485     static int myNbPresent;
486     Vectors_i();
487     Vectors_i(const Vectors_i&);
488   public:
489     Vectors_i(Result_i* theResult, bool theAddToStudy = true);
490     virtual void SameAs(const Vectors_i* theOrigin);
491     virtual ~Vectors_i();
492     virtual VISU::VISUType GetType() { return VISU::TVECTORS;};
493
494     virtual void SetLineWidth(CORBA::Double theWidth) { myLineWidth = theWidth;}
495     virtual CORBA::Double GetLineWidth() { return myLineWidth;}
496
497     virtual void SetGlyphType(VISU::Vectors::GlyphType theType) { myTypeGlyph = theType;}
498     virtual VISU::Vectors::GlyphType GetGlyphType() { return myTypeGlyph;}
499     
500     virtual void SetGlyphPos(VISU::Vectors::GlyphPos thePos) { myPosGlyph = thePos;}
501     virtual VISU::Vectors::GlyphPos GetGlyphPos() { return myPosGlyph;}
502
503     typedef VISU::Vectors InterfaceType;
504
505   protected:
506     virtual DataType* DoHook(int theRestoring);
507
508     float myLineWidth;
509     VISU::Vectors::GlyphType myTypeGlyph;
510     VISU::Vectors::GlyphPos myPosGlyph;
511     vtkGlyph3D *myGlyph;
512     vtkHedgeHog *myHog;
513
514   public:
515     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
516                              const char* theFieldName, double theIteration);
517     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
518       throw(std::logic_error&);
519     static const string myComment;
520     virtual const char* GetComment() const;
521     virtual QString GenerateName();
522     virtual void Update();
523     virtual void ToStream(ostrstream& theStr);
524     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
525                           const char* theFieldName, double theIteration);
526     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
527   };
528   Storable* VectorsRestore(SALOMEDS::SObject_ptr theSObject, 
529                            const string& thePrefix, const Storable::TRestoringMap& theMap)
530     throw(std::logic_error&);
531   //==============================================================================
532 }
533 #endif
534
535