Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/visu.git] / src / VISU_I / VISU_Result_i.hh
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 //  File   : VISU_Result_i.hh
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #ifndef __VISU_RESULT_I_H__
28 #define __VISU_RESULT_I_H__
29
30 #include "VISUConfig.hh"
31 #include "VISU_BoostSignals.h"
32 #include "SALOME_GenericObj_i.hh"
33
34 #include "VTKViewer.h"
35
36 #include <gp_Dir.hxx>
37 #include <vector>
38
39 class VISU_Convertor;
40
41 namespace VISU
42 {
43   //----------------------------------------------------------------------------
44   class MinMaxCunsomer: public virtual boost::signalslib::trackable
45   {
46   protected:
47     bool myMinMaxIsInitilized;
48     MinMaxCunsomer();
49
50   public:
51     virtual
52     bool
53     IsMinMaxInitilized();
54
55     virtual
56     void
57     UpdateMinMax();
58   };
59
60
61   //----------------------------------------------------------------------------
62   class Result_i : public virtual POA_VISU::Result,
63                    public virtual RemovableObject_i,
64                    public virtual SALOME::GenericObj_i
65   {
66     Result_i();
67     Result_i(const Result_i &);
68
69   public:
70     enum ESourceId {eRestoredComponent = -2, eRestoredFile = -1, eFile = 1, eComponent = 2};
71     enum ECreationId {eImportFile, eCopyAndImportFile, eImportMed, eImportMedField};
72
73     Result_i(SALOMEDS::Study_ptr theStudy,
74              const ESourceId& theSourceId,
75              const ECreationId& theCreationId,
76              CORBA::Boolean theIsBuildImmediately = true,
77              CORBA::Boolean theIsBuildFields = true,
78              CORBA::Boolean theIsBuildMinMax = true,
79              CORBA::Boolean theIsBuildGroups = true);
80
81     virtual ~Result_i();
82     virtual void RemoveFromStudy();
83
84     virtual VISU::VISUType GetType() { return VISU::TRESULT;}
85     virtual CORBA::Boolean BuildAll();
86
87     virtual CORBA::Boolean Build(CORBA::Boolean theIsBuildAll,
88                                  CORBA::Boolean theIsAtOnce);
89     virtual CORBA::Boolean IsDone();
90
91     virtual CORBA::Boolean IsEntitiesDone();
92
93     virtual void SetBuildFields(CORBA::Boolean theIsBuildFields, 
94                                 CORBA::Boolean theIsCalculateMinMax);
95     virtual CORBA::Boolean IsFieldsDone();
96
97     virtual void SetBuildGroups(CORBA::Boolean theIsBuildGroups);
98     virtual CORBA::Boolean IsGroupsDone();
99
100     virtual CORBA::Boolean IsMinMaxDone();
101
102     virtual 
103     void
104     MinMaxConnect(MinMaxCunsomer* theMinMaxCunsomer);
105
106     typedef boost::signal0<void> TUpdateMinMaxSignal;
107
108     typedef VISU_Convertor TInput;
109
110   private:
111     ESourceId mySourceId;
112     ECreationId myCreationId;
113
114     TInput *myInput;
115     std::string myName, myInitFileName;
116     QFileInfo myFileInfo;
117
118   protected:
119     virtual Storable* Build(SALOMEDS::SObject_ptr theSObject,
120                             CORBA::Boolean theIsAtOnce = true) ;
121     virtual Storable* BuildAll(SALOMEDS::SObject_ptr theSObject) ;
122
123     _PTR(Study) myStudy;
124     CORBA::Boolean myIsBuildImmediately;
125
126     CORBA::Boolean myIsEntitiesDone;
127     CORBA::Boolean myIsFieldsDone;
128     CORBA::Boolean myIsGroupsDone;
129     CORBA::Boolean myIsMinMaxDone;
130
131     CORBA::Boolean myIsBuildFields;
132     CORBA::Boolean myIsBuildGroups;
133
134     CORBA::Boolean myIsBuildMinMax;
135     TUpdateMinMaxSignal myUpdateMinMaxSignal;
136
137     CORBA::Boolean myIsAllDone;
138
139   public:
140     virtual int IsPossible();
141
142     virtual Storable* Create(const char* theFileName);
143     virtual Storable* Create(SALOMEDS::SObject_ptr theMedSObject);
144     virtual Storable* Create(SALOME_MED::FIELD_ptr theField);
145
146     virtual Storable* Restore(SALOMEDS::SObject_ptr theSObject,
147                               const Storable::TRestoringMap& theMap,
148                               const std::string& thePrefix);
149
150     static Storable* Restore(SALOMEDS::SObject_ptr theSObject,
151                              const std::string& thePrefix,
152                              const Storable::TRestoringMap& theMap);
153
154     virtual void ToStream(std::ostringstream& theStr);
155     virtual const char* GetComment() const;
156     static const std::string myComment;
157     TInput* GetInput();
158
159     const std::string& GetName() const { return myName;}
160     const QFileInfo& GetFileInfo() const { return myFileInfo;}
161     const std::string& GetFileName() const { return myInitFileName;}
162     const ECreationId& GetCreationId() const { return myCreationId;}
163
164   private:
165     SALOMEDS::SObject_var mySObject;
166     SALOMEDS::Study_var myStudyDocument;
167     SALOMEDS::SComponent_var mySComponent;
168
169   public:
170     std::string GetRefFatherEntry();
171     std::string GetEntry();
172     const SALOMEDS::SObject_var& GetSObject() const;
173     const SALOMEDS::Study_var& GetStudyDocument() const;
174     const SALOMEDS::SComponent_var& GetSComponent() const;
175     std::string GetEntry(const std::string& theComment);
176
177     // Info on structured mesh contained in TInput
178   public:
179     typedef enum { AXIS_X = 0, AXIS_Y, AXIS_Z } TAxis;
180     typedef std::vector< vtkFloatingPointType > TAxisInfo;
181     const TAxisInfo* GetAxisInfo(const std::string& theMeshName,
182                                  TAxis              theAxis,
183                                  gp_Dir&            thePlaneNormal);
184     // Return i,j or k values and cutting plane normal for theAxis.
185     // In the case of any problems, return NULL pointer
186   private:
187     struct TGridInfo {
188       TAxisInfo myComponets[ 3 ];
189       gp_Dir    myAxis     [ 3 ];
190     };
191     std::map< std::string, TGridInfo > myMeshName2GridInfoMap;
192   };
193
194   Result_var FindResult(SALOMEDS::SObject_ptr theSObject);
195 }
196
197 #endif