]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_Plot3D_i.cc
Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[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/ or email : webmaster.salome@opencascade.com
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 #include "SUIT_ResourceMgr.h"
30
31 using namespace VISU;
32 using namespace std;
33
34 #ifdef _DEBUG_
35 static int MYDEBUG = 0;
36 #else
37 static int MYDEBUG = 0;
38 #endif
39
40 int VISU::Plot3D_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
41                                const char* theFieldName, int theIteration, int isMemoryCheck)
42 {
43   return VISU::ScalarMap_i::IsPossible
44     (theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
45 }
46
47 int VISU::Plot3D_i::myNbPresent = 0;
48 QString VISU::Plot3D_i::GenerateName() { return VISU::GenerateName("Plot3D",myNbPresent++); }
49
50 const string VISU::Plot3D_i::myComment = "PLOT3D";
51 const char* VISU::Plot3D_i::GetComment() const { return myComment.c_str(); }
52
53 VISU::Plot3D_i
54 ::Plot3D_i(Result_i* theResult, 
55            bool theAddToStudy) :
56   PrsObject_i(theResult->GetStudyDocument()),
57   Prs3d_i(theResult,theAddToStudy),
58   ColoredPrs3d_i(theResult,theAddToStudy),
59   ScalarMap_i(theResult,theAddToStudy),
60   myPlot3DPL(NULL)
61 {}
62
63 VISU::Plot3D_i
64 ::Plot3D_i(Result_i* theResult, 
65            SALOMEDS::SObject_ptr theSObject) :
66   PrsObject_i(theResult->GetStudyDocument()),
67   Prs3d_i(theResult,theSObject),
68   ColoredPrs3d_i(theResult,theSObject),
69   ScalarMap_i(theResult,theSObject),
70   myPlot3DPL(NULL)
71 {}
72
73 VISU::Storable* VISU::Plot3D_i::Create (const char* theMeshName, VISU::Entity theEntity,
74                                         const char* theFieldName, int theIteration)
75 {
76   return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
77 }
78
79 VISU::Storable* VISU::Plot3D_i::Restore (const Storable::TRestoringMap& theMap)
80 {
81   TSuperClass::Restore(theMap);
82
83   SetOrientation(VISU::Plot3D::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()),
84                  Storable::FindValue(theMap,"aRot[0]").toDouble(),
85                  Storable::FindValue(theMap,"aRot[1]").toDouble());
86   SetPlanePosition(VISU::Storable::FindValue(theMap,"myPlanePosition").toDouble(),
87                    VISU::Storable::FindValue(theMap,"myPlaneCondition").toInt());
88   SetScaleFactor(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble());
89   SetContourPrs(VISU::Storable::FindValue(theMap,"myContourPrs").toInt());
90   SetNbOfContours(VISU::Storable::FindValue(theMap,"myNbOfContours").toInt());
91
92   return this;
93 }
94
95 void VISU::Plot3D_i::ToStream (std::ostringstream& theStr)
96 {
97   ScalarMap_i::ToStream(theStr);
98
99   Storable::DataToStream(theStr, "myBasePlane", int(GetOrientationType()));
100   Storable::DataToStream(theStr, "aRot[0]", GetRotateX());
101   Storable::DataToStream(theStr, "aRot[1]", GetRotateY());
102   Storable::DataToStream(theStr, "myPlanePosition", GetPlanePosition());
103   Storable::DataToStream(theStr, "myPlaneCondition", int(IsPositionRelative()));
104   Storable::DataToStream(theStr, "myScaleFactor", GetScaleFactor());
105   Storable::DataToStream(theStr, "myContourPrs", int(GetIsContourPrs()));
106   Storable::DataToStream(theStr, "myNbOfContours", int(GetNbOfContours()));
107 }
108
109 VISU::Plot3D_i::~Plot3D_i(){
110   if(MYDEBUG) MESSAGE("Plot3D_i::~Plot3D_i()");
111 }
112
113 void VISU::Plot3D_i::SetOrientation (VISU::Plot3D::Orientation theOrient,
114                                      CORBA::Double theXAngle, CORBA::Double theYAngle)
115 {
116   myPlot3DPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient),
117                              theXAngle,theYAngle);
118 }
119
120 VISU::Plot3D::Orientation VISU::Plot3D_i::GetOrientationType()
121 {
122   return VISU::Plot3D::Orientation(myPlot3DPL->GetPlaneOrientation());
123 }
124
125 CORBA::Double VISU::Plot3D_i::GetRotateX()
126 {
127   return myPlot3DPL->GetRotateX();
128 }
129
130 CORBA::Double VISU::Plot3D_i::GetRotateY()
131 {
132   return myPlot3DPL->GetRotateY();
133 }
134
135 void VISU::Plot3D_i::SetPlanePosition (CORBA::Double  thePlanePosition,
136                                        CORBA::Boolean theIsRelative)
137 {
138   myPlot3DPL->SetPlanePosition(thePlanePosition, theIsRelative);
139 }
140
141 CORBA::Double VISU::Plot3D_i::GetPlanePosition()
142 {
143   return myPlot3DPL->GetPlanePosition();
144 }
145
146 CORBA::Boolean VISU::Plot3D_i::IsPositionRelative()
147 {
148   return myPlot3DPL->IsPositionRelative();
149 }
150
151 void VISU::Plot3D_i::SetScaleFactor (CORBA::Double theScaleFactor)
152 {
153   myPlot3DPL->SetScaleFactor(theScaleFactor);
154 }
155
156 CORBA::Double VISU::Plot3D_i::GetScaleFactor()
157 {
158   return myPlot3DPL->GetScaleFactor();
159 }
160
161 void VISU::Plot3D_i::SetNbOfContours (CORBA::Long theNb)
162 {
163   myPlot3DPL->SetNumberOfContours(theNb);
164 }
165
166 CORBA::Long VISU::Plot3D_i::GetNbOfContours()
167 {
168   return myPlot3DPL->GetNumberOfContours();
169 }
170
171 void VISU::Plot3D_i::SetContourPrs (CORBA::Boolean theIsContourPrs )
172 {
173   myPlot3DPL->SetContourPrs( theIsContourPrs );
174 }
175
176 CORBA::Boolean VISU::Plot3D_i::GetIsContourPrs()
177 {
178   return myPlot3DPL->GetIsContourPrs();
179 }
180
181 void VISU::Plot3D_i::DoHook()
182 {
183   if (!myPipeLine) myPipeLine = VISU_Plot3DPL::New();
184   myPlot3DPL = dynamic_cast<VISU_Plot3DPL*>(myPipeLine);
185
186   ScalarMap_i::DoHook();
187 }
188
189 VISU_Actor* 
190 VISU::Plot3D_i
191 ::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
192 {
193   if(VISU_Actor* anActor = ScalarMap_i::CreateActor(theIO)){
194     anActor->SetVTKMapping(true);
195     SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
196     int aDispMode = aResourceMgr->integerValue("VISU", "plot3d_represent", 2);
197     anActor->SetRepresentation(aDispMode);
198     return anActor;
199   }
200   return NULL;
201 }
202
203 void VISU::Plot3D_i::SetMapScale(double theMapScale)
204 {
205   myPlot3DPL->SetMapScale(theMapScale);
206 }