]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_IsoSurfaces_i.cc
Salome HOME
sources v1.2c
[modules/visu.git] / src / VISU_I / VISU_IsoSurfaces_i.cc
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_PrsObject_i.cxx
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #include "VISU_IsoSurfacesPL.hxx"
28 #include "VISU_Result_i.hh"
29 #include "VISU_IsoSurfaces_i.hh"
30 #include "VISU_Actor.h"
31
32 using namespace VISU;
33 using namespace std;
34
35 #ifdef _DEBUG_
36 static int MYDEBUG = 0;
37 static int MYDEBUGWITHFILES = 0;
38 #else
39 static int MYDEBUG = 0;
40 static int MYDEBUGWITHFILES = 0;
41 #endif
42
43 int VISU::IsoSurfaces_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
44                                     const char* theFieldName, int theIteration)
45 {
46   return VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration);
47 }
48
49 int VISU::IsoSurfaces_i::myNbPresent = 0;
50 QString VISU::IsoSurfaces_i::GenerateName() { return VISU::GenerateName("IsoSurfaces",myNbPresent++);}
51
52 const string VISU::IsoSurfaces_i::myComment = "ISOSURFACES";
53 const char* VISU::IsoSurfaces_i::GetComment() const { return myComment.c_str();}
54
55 VISU::IsoSurfaces_i::IsoSurfaces_i(Result_i* theResult, bool theAddToStudy) :
56        PrsObject_i(theResult->GetStudyDocument()), 
57        Prs3d_i(theResult),       
58        ScalarMap_i(theResult, theAddToStudy)
59 {
60   myIsoSurfacesPL = NULL;
61 }
62
63 void VISU::IsoSurfaces_i::Destroy(){
64   ScalarMap_i::Destroy();
65 }
66
67 void VISU::IsoSurfaces_i::SameAs(const IsoSurfaces_i* theOrigin) {
68   IsoSurfaces_i* aIsoSurfaces = const_cast<IsoSurfaces_i*>(theOrigin);
69   VISU::ScalarMap_i::SameAs(theOrigin);
70
71   //SetNbSurfaces(aIsoSurfaces->GetNbSurfaces());
72   //SetSubRange(aIsoSurfaces->GetSubMin(),aIsoSurfaces->GetSubMax());
73 }
74
75 VISU::Storable* VISU::IsoSurfaces_i::Create(const char* theMeshName, VISU::Entity theEntity, 
76                                             const char* theFieldName, int theIteration)
77 {
78   return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration);
79 }
80
81 VISU::Storable* VISU::IsoSurfaces_i::Restore(const Storable::TRestoringMap& theMap)
82      throw(std::logic_error&)
83 {
84   ScalarMap_i::Restore(theMap);
85
86   SetNbSurfaces(VISU::Storable::FindValue(theMap,"myNbSurface").toInt());
87   float aMin = VISU::Storable::FindValue(theMap,"myRange[0]").toDouble();
88   float aMax = VISU::Storable::FindValue(theMap,"myRange[1]").toDouble();
89   SetSubRange(aMin,aMax);
90     
91   return Build(true);
92 }
93
94 void VISU::IsoSurfaces_i::ToStream(std::ostringstream& theStr){
95   ScalarMap_i::ToStream(theStr);
96
97   Storable::DataToStream( theStr, "myNbSurface", int(GetNbSurfaces()) );
98   Storable::DataToStream( theStr, "myRange[0]", GetSubMin() );
99   Storable::DataToStream( theStr, "myRange[1]", GetSubMax() );
100 }
101
102 VISU::Storable* VISU::IsoSurfaces_i::Restore(SALOMEDS::SObject_ptr theSObject, 
103                                              const string& thePrefix, const Storable::TRestoringMap& theMap)
104      throw(std::logic_error&)
105 {
106   VISU::Result_i* pResult = GetResult(theSObject);
107   if(pResult != NULL){
108     VISU::IsoSurfaces_i* pResent = new VISU::IsoSurfaces_i(pResult);
109     return pResent->Restore(theMap);
110   }
111   return NULL;
112 }
113
114
115 VISU::IsoSurfaces_i::~IsoSurfaces_i(){
116   if(MYDEBUG) MESSAGE("IsoSurfaces_i::~IsoSurfaces_i()");
117 }
118
119
120 void VISU::IsoSurfaces_i::SetNbSurfaces(CORBA::Long theNb){
121   myIsoSurfacesPL->SetNbParts(theNb);
122 }
123 CORBA::Long VISU::IsoSurfaces_i::GetNbSurfaces(){
124   return myIsoSurfacesPL->GetNbParts();
125 }
126
127
128 void VISU::IsoSurfaces_i::SetSubRange(CORBA::Double theMin, CORBA::Double theMax){ 
129   float aRange[2] = {theMin, theMax};
130   myIsoSurfacesPL->SetRange(aRange);
131 }
132 CORBA::Double VISU::IsoSurfaces_i::GetSubMin(){
133   return myIsoSurfacesPL->GetMin();
134 }
135 CORBA::Double VISU::IsoSurfaces_i::GetSubMax(){
136   return myIsoSurfacesPL->GetMax();
137 }
138
139
140 void VISU::IsoSurfaces_i::DoHook(){
141   if(MYDEBUG) MESSAGE("IsoSurfaces_i::DoHook()- "<<myPipeLine);
142   if(!myPipeLine) myPipeLine = VISU_IsoSurfacesPL::New();
143   myIsoSurfacesPL = dynamic_cast<VISU_IsoSurfacesPL*>(myPipeLine);
144
145   ScalarMap_i::DoHook();
146 }
147
148
149 void VISU::IsoSurfaces_i::SetMapScale(double theMapScale){
150   myIsoSurfacesPL->SetMapScale(theMapScale);
151 }