1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "VISU_Plot3D_i.hh"
23 #include "VISU_Result_i.hh"
25 #include "VISU_Plot3DPL.hxx"
27 #include "VISU_Actor.h"
29 #include "SUIT_ResourceMgr.h"
35 static int MYDEBUG = 0;
37 static int MYDEBUG = 0;
40 int VISU::Plot3D_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
41 const char* theFieldName, int theIteration, int isMemoryCheck)
43 return VISU::ScalarMap_i::IsPossible
44 (theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
47 int VISU::Plot3D_i::myNbPresent = 0;
48 QString VISU::Plot3D_i::GenerateName() { return VISU::GenerateName("Plot3D",myNbPresent++); }
50 const string VISU::Plot3D_i::myComment = "PLOT3D";
51 const char* VISU::Plot3D_i::GetComment() const { return myComment.c_str(); }
54 ::Plot3D_i(Result_i* theResult,
56 PrsObject_i(theResult->GetStudyDocument()),
57 Prs3d_i(theResult,theAddToStudy),
58 ColoredPrs3d_i(theResult,theAddToStudy),
59 ScalarMap_i(theResult,theAddToStudy),
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),
73 VISU::Storable* VISU::Plot3D_i::Create (const char* theMeshName, VISU::Entity theEntity,
74 const char* theFieldName, int theIteration)
76 return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
79 VISU::Storable* VISU::Plot3D_i::Restore (const Storable::TRestoringMap& theMap)
81 TSuperClass::Restore(theMap);
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());
95 void VISU::Plot3D_i::ToStream (std::ostringstream& theStr)
97 ScalarMap_i::ToStream(theStr);
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()));
109 VISU::Plot3D_i::~Plot3D_i(){
110 if(MYDEBUG) MESSAGE("Plot3D_i::~Plot3D_i()");
113 void VISU::Plot3D_i::SetOrientation (VISU::Plot3D::Orientation theOrient,
114 CORBA::Double theXAngle, CORBA::Double theYAngle)
116 myPlot3DPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient),
117 theXAngle,theYAngle);
120 VISU::Plot3D::Orientation VISU::Plot3D_i::GetOrientationType()
122 return VISU::Plot3D::Orientation(myPlot3DPL->GetPlaneOrientation());
125 CORBA::Double VISU::Plot3D_i::GetRotateX()
127 return myPlot3DPL->GetRotateX();
130 CORBA::Double VISU::Plot3D_i::GetRotateY()
132 return myPlot3DPL->GetRotateY();
135 void VISU::Plot3D_i::SetPlanePosition (CORBA::Double thePlanePosition,
136 CORBA::Boolean theIsRelative)
138 myPlot3DPL->SetPlanePosition(thePlanePosition, theIsRelative);
141 CORBA::Double VISU::Plot3D_i::GetPlanePosition()
143 return myPlot3DPL->GetPlanePosition();
146 CORBA::Boolean VISU::Plot3D_i::IsPositionRelative()
148 return myPlot3DPL->IsPositionRelative();
151 void VISU::Plot3D_i::SetScaleFactor (CORBA::Double theScaleFactor)
153 myPlot3DPL->SetScaleFactor(theScaleFactor);
156 CORBA::Double VISU::Plot3D_i::GetScaleFactor()
158 return myPlot3DPL->GetScaleFactor();
161 void VISU::Plot3D_i::SetNbOfContours (CORBA::Long theNb)
163 myPlot3DPL->SetNumberOfContours(theNb);
166 CORBA::Long VISU::Plot3D_i::GetNbOfContours()
168 return myPlot3DPL->GetNumberOfContours();
171 void VISU::Plot3D_i::SetContourPrs (CORBA::Boolean theIsContourPrs )
173 myPlot3DPL->SetContourPrs( theIsContourPrs );
176 CORBA::Boolean VISU::Plot3D_i::GetIsContourPrs()
178 return myPlot3DPL->GetIsContourPrs();
181 void VISU::Plot3D_i::DoHook()
183 if (!myPipeLine) myPipeLine = VISU_Plot3DPL::New();
184 myPlot3DPL = dynamic_cast<VISU_Plot3DPL*>(myPipeLine);
186 ScalarMap_i::DoHook();
191 ::CreateActor(const Handle(SALOME_InteractiveObject)& theIO)
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);
203 void VISU::Plot3D_i::SetMapScale(double theMapScale)
205 myPlot3DPL->SetMapScale(theMapScale);