1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : VISU_PrsObject_i.cxx
24 // Author : Alexey PETROV
27 #include "VISU_IsoSurfaces_i.hh"
28 #include "VISU_Prs3dUtils.hh"
30 #include "VISU_IsoSurfacesPL.hxx"
31 #include "VISU_Result_i.hh"
32 #include "VISU_Actor.h"
34 #include "SUIT_ResourceMgr.h"
35 #include "SALOME_Event.hxx"
38 static int MYDEBUG = 0;
40 static int MYDEBUG = 0;
43 //---------------------------------------------------------------
46 ::IsPossible(Result_i* theResult,
47 const std::string& theMeshName,
48 VISU::Entity theEntity,
49 const std::string& theFieldName,
50 CORBA::Long theTimeStampNumber,
51 bool theIsMemoryCheck)
53 return TSuperClass::IsPossible(theResult,
61 //---------------------------------------------------------------
62 int VISU::IsoSurfaces_i::myNbPresent = 0;
64 //---------------------------------------------------------------
65 QString VISU::IsoSurfaces_i::GenerateName()
67 return VISU::GenerateName("IsoSurfaces",myNbPresent++);
70 //---------------------------------------------------------------
71 const string VISU::IsoSurfaces_i::myComment = "ISOSURFACES";
73 //---------------------------------------------------------------
78 return myComment.c_str();
81 //---------------------------------------------------------------
87 return "ICON_TREE_ISO_SURFACES";
89 return "ICON_TREE_ISO_SURFACES_GROUPS";
92 //---------------------------------------------------------------
94 ::IsoSurfaces_i(EPublishInStudyMode thePublishInStudyMode) :
95 ColoredPrs3d_i(thePublishInStudyMode),
96 ScalarMap_i(thePublishInStudyMode),
101 //---------------------------------------------------------------
104 ::Create(const std::string& theMeshName,
105 VISU::Entity theEntity,
106 const std::string& theFieldName,
107 CORBA::Long theTimeStampNumber)
109 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
113 //---------------------------------------------------------------
116 ::Restore(SALOMEDS::SObject_ptr theSObject,
117 const Storable::TRestoringMap& theMap)
119 if(!TSuperClass::Restore(theSObject, theMap))
122 SetNbSurfaces(VISU::Storable::FindValue(theMap,"myNbSurface").toInt());
123 float aMin = VISU::Storable::FindValue(theMap,"myRange[0]").toDouble();
124 float aMax = VISU::Storable::FindValue(theMap,"myRange[1]").toDouble();
125 SetSubRange(aMin,aMax);
131 //---------------------------------------------------------------
134 ::ToStream(std::ostringstream& theStr)
136 TSuperClass::ToStream(theStr);
138 Storable::DataToStream( theStr, "myNbSurface", int(GetNbSurfaces()) );
139 Storable::DataToStream( theStr, "myRange[0]", GetSubMin() );
140 Storable::DataToStream( theStr, "myRange[1]", GetSubMax() );
144 //---------------------------------------------------------------
148 if(MYDEBUG) MESSAGE("IsoSurfaces_i::~IsoSurfaces_i()");
152 //---------------------------------------------------------------
155 ::SetNbSurfaces(CORBA::Long theNb)
157 VISU::TSetModified aModified(this);
159 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_IsoSurfacesPL, int>
160 (GetSpecificPL(), &VISU_IsoSurfacesPL::SetNbParts, theNb));
163 //---------------------------------------------------------------
168 return myIsoSurfacesPL->GetNbParts();
172 //---------------------------------------------------------------
175 ::SetSubRange(CORBA::Double theMin, CORBA::Double theMax)
177 VISU::TSetModified aModified(this);
179 vtkFloatingPointType aRange[2] = {theMin, theMax};
180 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_IsoSurfacesPL, vtkFloatingPointType*>
181 (GetSpecificPL(), &VISU_IsoSurfacesPL::SetRange, aRange));
184 //---------------------------------------------------------------
189 return myIsoSurfacesPL->GetMin();
192 //---------------------------------------------------------------
197 return myIsoSurfacesPL->GetMax();
201 //---------------------------------------------------------------
204 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
207 myIsoSurfacesPL = VISU_IsoSurfacesPL::New();
209 myIsoSurfacesPL = dynamic_cast<VISU_IsoSurfacesPL*>(thePipeLine);
211 TSuperClass::CreatePipeLine(myIsoSurfacesPL);
215 //----------------------------------------------------------------------------
218 ::DoSetInput(bool theIsInitilizePipe, bool theReInit)
220 TSuperClass::DoSetInput(theIsInitilizePipe, theReInit);
221 if(theIsInitilizePipe || (!IsTimeStampFixed() && !IsRangeFixed()) || theReInit)
222 SetSubRange(GetSourceMin(), GetSourceMax());
225 //---------------------------------------------------------------
230 return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true);
233 //---------------------------------------------------------------
238 if(VISU_Actor* anActor = TSuperClass::CreateActor()){
239 anActor->SetVTKMapping(true);
240 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
241 int aDispMode = aResourceMgr->integerValue("VISU" , "iso_surfaces_represent", 2);
242 anActor->SetRepresentation(aDispMode);
249 //---------------------------------------------------------------
252 ::SetMapScale(double theMapScale)
254 myIsoSurfacesPL->SetMapScale(theMapScale);