Salome HOME
Call to disappeared method QtxWorkstack::OnTop() replaced by call to QWidget::setFocus()
[modules/visu.git] / src / VISU_I / VISU_Plot3D_i.cc
1
2 #include "VISU_Plot3D_i.hh"
3
4 #include "VISU_Result_i.hh"
5
6 #include "VISU_Plot3DPL.hxx"
7
8 #include "VISU_Actor.h"
9
10 using namespace VISU;
11 using namespace std;
12
13 #ifdef _DEBUG_
14 static int MYDEBUG = 0;
15 #else
16 static int MYDEBUG = 0;
17 #endif
18
19 int VISU::Plot3D_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
20                                const char* theFieldName, int theIteration, int isMemoryCheck)
21 {
22   return VISU::ScalarMap_i::IsPossible
23     (theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck);
24 }
25
26 int VISU::Plot3D_i::myNbPresent = 0;
27 QString VISU::Plot3D_i::GenerateName() { return VISU::GenerateName("Plot3D",myNbPresent++); }
28
29 const string VISU::Plot3D_i::myComment = "PLOT3D";
30 const char* VISU::Plot3D_i::GetComment() const { return myComment.c_str(); }
31
32 VISU::Plot3D_i::Plot3D_i (Result_i* theResult, bool theAddToStudy)
33      : PrsObject_i(theResult->GetStudyDocument()),
34        Prs3d_i(theResult,theAddToStudy),
35        ScalarMap_i(theResult,theAddToStudy),
36        myPlot3DPL(NULL)
37 {
38 }
39
40 VISU::Plot3D_i::Plot3D_i (Result_i* theResult, SALOMEDS::SObject_ptr theSObject)
41      : PrsObject_i(theResult->GetStudyDocument()),
42        Prs3d_i(theResult,theSObject),
43        ScalarMap_i(theResult,theSObject),
44        myPlot3DPL(NULL)
45 {
46 }
47
48 void VISU::Plot3D_i::SameAs (const Plot3D_i* theOrigin)
49 {
50   VISU::ScalarMap_i::SameAs(theOrigin);
51 }
52
53 VISU::Storable* VISU::Plot3D_i::Create (const char* theMeshName, VISU::Entity theEntity,
54                                         const char* theFieldName, int theIteration)
55 {
56   return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
57 }
58
59 VISU::Storable* VISU::Plot3D_i::Restore (const Storable::TRestoringMap& theMap)
60 {
61   DoHook();
62   SetOrientation(VISU::Plot3D::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane").toInt()),
63                  Storable::FindValue(theMap,"aRot[0]").toDouble(),
64                  Storable::FindValue(theMap,"aRot[1]").toDouble());
65   SetPlanePosition(VISU::Storable::FindValue(theMap,"myPlanePosition").toDouble(),
66                    VISU::Storable::FindValue(theMap,"myPlaneCondition").toInt());
67   SetScaleFactor(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble());
68   SetContourPrs(VISU::Storable::FindValue(theMap,"myContourPrs").toInt());
69   SetNbOfContours(VISU::Storable::FindValue(theMap,"myNbOfContours").toInt());
70
71   return ScalarMap_i::Restore(theMap);
72 }
73
74 void VISU::Plot3D_i::ToStream (std::ostringstream& theStr)
75 {
76   ScalarMap_i::ToStream(theStr);
77
78   Storable::DataToStream(theStr, "myBasePlane", int(GetOrientationType()));
79   Storable::DataToStream(theStr, "aRot[0]", GetRotateX());
80   Storable::DataToStream(theStr, "aRot[1]", GetRotateY());
81   Storable::DataToStream(theStr, "myPlanePosition", GetPlanePosition());
82   Storable::DataToStream(theStr, "myPlaneCondition", int(IsPositionRelative()));
83   Storable::DataToStream(theStr, "myScaleFactor", GetScaleFactor());
84   Storable::DataToStream(theStr, "myContourPrs", int(GetIsContourPrs()));
85   Storable::DataToStream(theStr, "myNbOfContours", int(GetNbOfContours()));
86 }
87
88 VISU::Plot3D_i::~Plot3D_i(){
89   if(MYDEBUG) MESSAGE("Plot3D_i::~Plot3D_i()");
90 }
91
92 void VISU::Plot3D_i::SetOrientation (VISU::Plot3D::Orientation theOrient,
93                                      CORBA::Double theXAngle, CORBA::Double theYAngle)
94 {
95   myPlot3DPL->SetOrientation(VISU_CutPlanesPL::PlaneOrientation(theOrient),
96                              theXAngle,theYAngle);
97 }
98
99 VISU::Plot3D::Orientation VISU::Plot3D_i::GetOrientationType()
100 {
101   return VISU::Plot3D::Orientation(myPlot3DPL->GetPlaneOrientation());
102 }
103
104 CORBA::Double VISU::Plot3D_i::GetRotateX()
105 {
106   return myPlot3DPL->GetRotateX();
107 }
108
109 CORBA::Double VISU::Plot3D_i::GetRotateY()
110 {
111   return myPlot3DPL->GetRotateY();
112 }
113
114 void VISU::Plot3D_i::SetPlanePosition (CORBA::Double  thePlanePosition,
115                                        CORBA::Boolean theIsRelative)
116 {
117   myPlot3DPL->SetPlanePosition(thePlanePosition, theIsRelative);
118 }
119
120 CORBA::Double VISU::Plot3D_i::GetPlanePosition()
121 {
122   return myPlot3DPL->GetPlanePosition();
123 }
124
125 CORBA::Boolean VISU::Plot3D_i::IsPositionRelative()
126 {
127   return myPlot3DPL->IsPositionRelative();
128 }
129
130 void VISU::Plot3D_i::SetScaleFactor (CORBA::Double theScaleFactor)
131 {
132   myPlot3DPL->SetScaleFactor(theScaleFactor);
133 }
134
135 CORBA::Double VISU::Plot3D_i::GetScaleFactor()
136 {
137   return myPlot3DPL->GetScaleFactor();
138 }
139
140 void VISU::Plot3D_i::SetNbOfContours (CORBA::Long theNb)
141 {
142   myPlot3DPL->SetNumberOfContours(theNb);
143 }
144
145 CORBA::Long VISU::Plot3D_i::GetNbOfContours()
146 {
147   return myPlot3DPL->GetNumberOfContours();
148 }
149
150 void VISU::Plot3D_i::SetContourPrs (CORBA::Boolean theIsContourPrs )
151 {
152   myPlot3DPL->SetContourPrs( theIsContourPrs );
153 }
154
155 CORBA::Boolean VISU::Plot3D_i::GetIsContourPrs()
156 {
157   return myPlot3DPL->GetIsContourPrs();
158 }
159
160 void VISU::Plot3D_i::DoHook()
161 {
162   if (!myPipeLine) myPipeLine = VISU_Plot3DPL::New();
163   myPlot3DPL = dynamic_cast<VISU_Plot3DPL*>(myPipeLine);
164
165   ScalarMap_i::DoHook();
166 }
167
168 void VISU::Plot3D_i::SetMapScale(double theMapScale)
169 {
170   myPlot3DPL->SetMapScale(theMapScale);
171 }