]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_Plot3D_i.cc
Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / VISU_I / VISU_Plot3D_i.cc
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/
19 //
20
21 #include "VISU_Plot3D_i.hh"
22
23 #include "VISU_Result_i.hh"
24
25 #include "VISU_Plot3DPL.hxx"
26
27 #include "VISU_Actor.h"
28
29 using namespace VISU;
30 using namespace std;
31
32 #ifdef _DEBUG_
33 static int MYDEBUG = 0;
34 #else
35 static int MYDEBUG = 0;
36 #endif
37
38 int VISU::Plot3D_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
39                                const char* theFieldName, int theIteration, int isMemoryCheck)
40 {
41   return VISU::ScalarMap_i::IsPossible
42     (theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
43 }
44
45 int VISU::Plot3D_i::myNbPresent = 0;
46 QString VISU::Plot3D_i::GenerateName() { return VISU::GenerateName("Plot3D",myNbPresent++); }
47
48 const string VISU::Plot3D_i::myComment = "PLOT3D";
49 const char* VISU::Plot3D_i::GetComment() const { return myComment.c_str(); }
50
51 VISU::Plot3D_i
52 ::Plot3D_i(Result_i* theResult, 
53            bool theAddToStudy) :
54   PrsObject_i(theResult->GetStudyDocument()),
55   Prs3d_i(theResult,theAddToStudy),
56   ColoredPrs3d_i(theResult,theAddToStudy),
57   ScalarMap_i(theResult,theAddToStudy),
58   myPlot3DPL(NULL)
59 {}
60
61 VISU::Plot3D_i
62 ::Plot3D_i(Result_i* theResult, 
63            SALOMEDS::SObject_ptr theSObject) :
64   PrsObject_i(theResult->GetStudyDocument()),
65   Prs3d_i(theResult,theSObject),
66   ColoredPrs3d_i(theResult,theSObject),
67   ScalarMap_i(theResult,theSObject),
68   myPlot3DPL(NULL)
69 {}
70
71 VISU::Storable* VISU::Plot3D_i::Create (const char* theMeshName, VISU::Entity theEntity,
72                                         const char* theFieldName, int theIteration)
73 {
74   return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
75 }
76
77 VISU::Storable* VISU::Plot3D_i::Restore (const Storable::TRestoringMap& theMap)
78 {
79   TSuperClass::Restore(theMap);
80
81   SetOrientation(VISU::Plot3D::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()),
82                  Storable::FindValue(theMap,"aRot[0]").toDouble(),
83                  Storable::FindValue(theMap,"aRot[1]").toDouble());
84   SetPlanePosition(VISU::Storable::FindValue(theMap,"myPlanePosition").toDouble(),
85                    VISU::Storable::FindValue(theMap,"myPlaneCondition").toInt());
86   SetScaleFactor(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble());
87   SetContourPrs(VISU::Storable::FindValue(theMap,"myContourPrs").toInt());
88   SetNbOfContours(VISU::Storable::FindValue(theMap,"myNbOfContours").toInt());
89
90   return this;
91 }
92
93 void VISU::Plot3D_i::ToStream (std::ostringstream& theStr)
94 {
95   ScalarMap_i::ToStream(theStr);
96
97   Storable::DataToStream(theStr, "myBasePlane", int(GetOrientationType()));
98   Storable::DataToStream(theStr, "aRot[0]", GetRotateX());
99   Storable::DataToStream(theStr, "aRot[1]", GetRotateY());
100   Storable::DataToStream(theStr, "myPlanePosition", GetPlanePosition());
101   Storable::DataToStream(theStr, "myPlaneCondition", int(IsPositionRelative()));
102   Storable::DataToStream(theStr, "myScaleFactor", GetScaleFactor());
103   Storable::DataToStream(theStr, "myContourPrs", int(GetIsContourPrs()));
104   Storable::DataToStream(theStr, "myNbOfContours", int(GetNbOfContours()));
105 }
106
107 VISU::Plot3D_i::~Plot3D_i(){
108   if(MYDEBUG) MESSAGE("Plot3D_i::~Plot3D_i()");
109 }
110
111 void VISU::Plot3D_i::SetOrientation (VISU::Plot3D::Orientation theOrient,
112                                      CORBA::Double theXAngle, CORBA::Double theYAngle)
113 {
114   myPlot3DPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient),
115                              theXAngle,theYAngle);
116 }
117
118 VISU::Plot3D::Orientation VISU::Plot3D_i::GetOrientationType()
119 {
120   return VISU::Plot3D::Orientation(myPlot3DPL->GetPlaneOrientation());
121 }
122
123 CORBA::Double VISU::Plot3D_i::GetRotateX()
124 {
125   return myPlot3DPL->GetRotateX();
126 }
127
128 CORBA::Double VISU::Plot3D_i::GetRotateY()
129 {
130   return myPlot3DPL->GetRotateY();
131 }
132
133 void VISU::Plot3D_i::SetPlanePosition (CORBA::Double  thePlanePosition,
134                                        CORBA::Boolean theIsRelative)
135 {
136   myPlot3DPL->SetPlanePosition(thePlanePosition, theIsRelative);
137 }
138
139 CORBA::Double VISU::Plot3D_i::GetPlanePosition()
140 {
141   return myPlot3DPL->GetPlanePosition();
142 }
143
144 CORBA::Boolean VISU::Plot3D_i::IsPositionRelative()
145 {
146   return myPlot3DPL->IsPositionRelative();
147 }
148
149 void VISU::Plot3D_i::SetScaleFactor (CORBA::Double theScaleFactor)
150 {
151   myPlot3DPL->SetScaleFactor(theScaleFactor);
152 }
153
154 CORBA::Double VISU::Plot3D_i::GetScaleFactor()
155 {
156   return myPlot3DPL->GetScaleFactor();
157 }
158
159 void VISU::Plot3D_i::SetNbOfContours (CORBA::Long theNb)
160 {
161   myPlot3DPL->SetNumberOfContours(theNb);
162 }
163
164 CORBA::Long VISU::Plot3D_i::GetNbOfContours()
165 {
166   return myPlot3DPL->GetNumberOfContours();
167 }
168
169 void VISU::Plot3D_i::SetContourPrs (CORBA::Boolean theIsContourPrs )
170 {
171   myPlot3DPL->SetContourPrs( theIsContourPrs );
172 }
173
174 CORBA::Boolean VISU::Plot3D_i::GetIsContourPrs()
175 {
176   return myPlot3DPL->GetIsContourPrs();
177 }
178
179 void VISU::Plot3D_i::DoHook()
180 {
181   if (!myPipeLine) myPipeLine = VISU_Plot3DPL::New();
182   myPlot3DPL = dynamic_cast<VISU_Plot3DPL*>(myPipeLine);
183
184   ScalarMap_i::DoHook();
185 }
186
187 VISU_Actor* 
188 VISU::Plot3D_i
189 ::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
190 {
191   if(VISU_Actor* anActor = ScalarMap_i::CreateActor(theIO)){
192     anActor->SetVTKMapping(true);
193     return anActor;
194   }
195   return NULL;
196 }
197
198 void VISU::Plot3D_i::SetMapScale(double theMapScale)
199 {
200   myPlot3DPL->SetMapScale(theMapScale);
201 }