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