]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_PrsObject_i.hh
Salome HOME
NRI : Remove dependence with KERNEL.
[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     const VISU::TField*  GetField() const { return myField;}
250     const string&  GetFieldName() const { return myFieldName;}
251     int GetScalarMode() const { return myScalarMode;}
252
253     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
254   };
255   Storable* ScalarMapRestore(SALOMEDS::SObject_ptr theSObject, 
256                              const string& thePrefix, const Storable::TRestoringMap& theMap)
257     throw(std::logic_error&);
258
259
260   //==============================================================================
261   class DeformedShape_i : public virtual POA_VISU::DeformedShape,
262                           public virtual ScalarMap_i
263   {
264     static int myNbPresent;
265     DeformedShape_i();
266     DeformedShape_i(const DeformedShape_i&);
267   public:
268     DeformedShape_i(Result_i* theResult, bool theAddToStudy = true);
269     virtual void SameAs(const DeformedShape_i* theOrigin);
270     virtual ~DeformedShape_i();
271
272     virtual VISU::VISUType GetType() { return VISU::TDEFORMEDSHAPE;};
273
274     virtual void SetScale(CORBA::Double theScale) { myFactor = theScale;}
275     virtual CORBA::Double GetScale() { return myFactor;}
276
277     typedef VISU::DeformedShape InterfaceType;
278
279     virtual bool isColored() { return myIsColored; }
280     virtual void setColored(bool theColor) 
281     { myIsColored = theColor; }
282
283   protected:
284     virtual DataType* DoHook(int theRestoring);
285     float myFactor;
286     bool myIsColored;
287     vtkWarpVector *myWarpVector;
288
289   public:
290     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
291                              const char* theFieldName, double theIteration);
292     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
293       throw(std::logic_error&);
294     static const string myComment;
295     virtual const char* GetComment() const;
296     virtual QString GenerateName();
297     virtual void Update();
298     virtual void ToStream(ostrstream& theStr);
299     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
300                           const char* theFieldName, double theIteration);
301     float ScaleFactor();
302
303     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
304   };
305   Storable* DeformedShapeRestore(SALOMEDS::SObject_ptr theSObject, 
306                                  const string& thePrefix, const Storable::TRestoringMap& theMap)
307     throw(std::logic_error&);
308
309
310
311
312   //==============================================================================
313   class CutPlanes_i : public virtual POA_VISU::CutPlanes,
314                       public virtual ScalarMap_i
315   {
316     static int myNbPresent;
317     CutPlanes_i();
318     CutPlanes_i(const CutPlanes_i&);
319   public:
320     CutPlanes_i(Result_i* theResult, bool theAddToStudy = true);
321     virtual void SameAs(const CutPlanes_i* theOrigin);
322     virtual ~CutPlanes_i();
323     virtual VISU::VISUType GetType() { return VISU::TCUTPLANES;};
324
325     virtual void SetOrientationType(VISU::CutPlanes::Orientation theOrient) { 
326       myBasePlane = theOrient;
327     }
328     virtual VISU::CutPlanes::Orientation GetOrientationType() { return myBasePlane;}
329
330     virtual void SetNbPlanes(CORBA::Long theNb) { myNbPlanes = theNb;}
331     virtual CORBA::Long GetNbPlanes() { return myNbPlanes;}
332     
333     virtual void SetRotateX(CORBA::Double theAngle);
334     virtual CORBA::Double GetRotateX();
335     virtual void SetRotateY(CORBA::Double theAngle);
336     virtual CORBA::Double GetRotateY();
337     
338     typedef VISU::CutPlanes InterfaceType;
339
340   protected:
341     virtual DataType* DoHook(int theRestoring);
342
343     float myRotation[3][3];
344     float myAng[3], myDir[3], myInvDir[3], myBoundPrj[3], myDBPrj;
345     vtkAppendPolyData *myAppendPolyData;
346     VISU::CutPlanes::Orientation myBasePlane;
347     int myNbPlanes;
348
349   public:
350     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
351                              const char* theFieldName, double theIteration);
352     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
353       throw(std::logic_error&);
354     static const string myComment;
355     virtual const char* GetComment() const;
356     virtual QString GenerateName();
357     virtual void Update();
358     virtual void ToStream(ostrstream& theStr);
359     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
360                           const char* theFieldName, double theIteration);
361     void SetPlane(int theId);
362
363     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
364   };
365   Storable* CutPlanesRestore(SALOMEDS::SObject_ptr theSObject, 
366                              const string& thePrefix, const Storable::TRestoringMap& theMap)
367     throw(std::logic_error&);
368
369
370
371   //==============================================================================
372   class IsoSurfaces_i : public virtual POA_VISU::IsoSurfaces,
373                         public virtual ScalarMap_i
374   {
375     static int myNbPresent;
376     IsoSurfaces_i();
377     IsoSurfaces_i(const IsoSurfaces_i&);
378   public:
379     IsoSurfaces_i(Result_i* theResult, bool theAddToStudy = true);
380     virtual void SameAs(const IsoSurfaces_i* theOrigin);
381     virtual ~IsoSurfaces_i();
382     virtual VISU::VISUType GetType() { return VISU::TISOSURFACE;};
383
384     virtual void SetNbSurfaces(CORBA::Long theNb) { myNbSurface = theNb;}
385     virtual CORBA::Long GetNbSurfaces() { return myNbSurface;}
386
387     virtual void SetRange(float theMin, float theMax)
388     { myRange[0] = theMin;  myRange[1] = theMax; }
389
390     virtual float GetRangeMin() { return myRange[0]; }
391     virtual float GetRangeMax() { return myRange[1]; }
392
393     typedef VISU::IsoSurfaces InterfaceType;
394
395   protected:
396     virtual DataType* DoHook(int theRestoring);
397
398     vtkContourFilter *myContourFilter;
399     int myNbSurface;
400     float myRange[2];
401
402   public:
403     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
404                              const char* theFieldName, double theIteration);
405     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
406       throw(std::logic_error&);
407     static const string myComment;
408     virtual const char* GetComment() const;
409     virtual QString GenerateName();
410     virtual void Update();
411     virtual void ToStream(ostrstream& theStr);
412     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
413                           const char* theFieldName, double theIteration);
414     vtkContourFilter* GetFilter() { return myContourFilter;}
415     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
416   };
417   Storable* IsoSurfacesRestore(SALOMEDS::SObject_ptr theSObject, 
418                                const string& thePrefix, const Storable::TRestoringMap& theMap)
419     throw(std::logic_error&);
420
421
422
423   //==============================================================================
424   class StreamLines_i : public virtual POA_VISU::StreamLines,
425                         public virtual DeformedShape_i
426   {
427     static int myNbPresent;
428     StreamLines_i();
429     StreamLines_i(const StreamLines_i&);
430   public:
431     StreamLines_i(Result_i* theResult, bool theAddToStudy = true);
432     virtual void SameAs(const StreamLines_i* theOriginal);
433     virtual ~StreamLines_i();
434
435     virtual VISU::VISUType GetType() { return VISU::TSTREAMLINES;}
436
437     typedef VISU::StreamLines InterfaceType;
438
439     virtual void SetDirection(VISU::StreamLines::Direction theDirection) 
440     { myDirection = theDirection; }
441     virtual VISU::StreamLines::Direction GetDirection() { return myDirection;}
442
443     virtual void SetStepLength(float theStep) { myStepLength = theStep; }
444     virtual float GetStepLength() { return myStepLength; }
445
446     virtual void SetPropagationTime(float theTime) { myPropagationTime = theTime; }
447     virtual float GetPropagationTime() { return myPropagationTime; }
448
449     virtual void SetIntegrationStep(float theStep) { myIntegrationStep = theStep; }
450     virtual float GetIntegrationStep() { return myIntegrationStep; }
451
452   protected:
453     virtual DataType* DoHook(int theRestoring);
454     vtkStreamLine* myStream;
455
456     VISU::StreamLines::Direction myDirection;
457     float myStepLength;
458     float myIntegrationStep;
459     float myPropagationTime;
460
461   public:
462     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
463                              const char* theFieldName, double theIteration);
464     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
465       throw(std::logic_error&);
466     static const string myComment;
467     virtual const char* GetComment() const;
468     virtual QString GenerateName();
469     virtual void Update();
470     virtual void ToStream(ostrstream& theStr);
471     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
472                           const char* theFieldName, double theIteration);
473     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
474   };
475   Storable* StreamLinesRestore(SALOMEDS::SObject_ptr theSObject, 
476                                const string& thePrefix, const Storable::TRestoringMap& theMap)
477     throw(std::logic_error&);
478
479
480   //==============================================================================
481   class Vectors_i : public virtual POA_VISU::Vectors,
482                     public virtual DeformedShape_i
483   {
484     static int myNbPresent;
485     Vectors_i();
486     Vectors_i(const Vectors_i&);
487   public:
488     Vectors_i(Result_i* theResult, bool theAddToStudy = true);
489     virtual void SameAs(const Vectors_i* theOrigin);
490     virtual ~Vectors_i();
491     virtual VISU::VISUType GetType() { return VISU::TVECTORS;};
492
493     virtual void SetLineWidth(CORBA::Double theWidth) { myLineWidth = theWidth;}
494     virtual CORBA::Double GetLineWidth() { return myLineWidth;}
495
496     virtual void SetGlyphType(VISU::Vectors::GlyphType theType) { myTypeGlyph = theType;}
497     virtual VISU::Vectors::GlyphType GetGlyphType() { return myTypeGlyph;}
498     
499     virtual void SetGlyphPos(VISU::Vectors::GlyphPos thePos) { myPosGlyph = thePos;}
500     virtual VISU::Vectors::GlyphPos GetGlyphPos() { return myPosGlyph;}
501
502     typedef VISU::Vectors InterfaceType;
503
504   protected:
505     virtual DataType* DoHook(int theRestoring);
506
507     float myLineWidth;
508     VISU::Vectors::GlyphType myTypeGlyph;
509     VISU::Vectors::GlyphPos myPosGlyph;
510     vtkGlyph3D *myGlyph;
511     vtkHedgeHog *myHog;
512
513   public:
514     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
515                              const char* theFieldName, double theIteration);
516     virtual Storable* Restore(const Storable::TRestoringMap& theMap, int theBuilding = true)
517       throw(std::logic_error&);
518     static const string myComment;
519     virtual const char* GetComment() const;
520     virtual QString GenerateName();
521     virtual void Update();
522     virtual void ToStream(ostrstream& theStr);
523     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
524                           const char* theFieldName, double theIteration);
525     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
526   };
527   Storable* VectorsRestore(SALOMEDS::SObject_ptr theSObject, 
528                            const string& thePrefix, const Storable::TRestoringMap& theMap)
529     throw(std::logic_error&);
530   //==============================================================================
531 }
532 #endif
533
534