1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_PrsObject_i.cxx
24 // Author : Alexey PETROV
27 #include "VISU_DeformedShape_i.hh"
28 #include "VISU_Prs3dUtils.hh"
29 #include "VISU_Result_i.hh"
31 #include "VISU_ScalarMapAct.h"
32 #include "VISU_DeformedShapePL.hxx"
33 #include "VISU_PipeLineUtils.hxx"
34 #include "VISU_Convertor.hxx"
36 #include "SUIT_ResourceMgr.h"
37 #include "SALOME_Event.h"
39 #include <vtkDataSetMapper.h>
40 #include <vtkProperty.h>
43 static int MYDEBUG = 0;
45 static int MYDEBUG = 0;
50 //---------------------------------------------------------------
53 ::IsPossible(Result_i* theResult,
54 const std::string& theMeshName,
55 VISU::Entity theEntity,
56 const std::string& theFieldName,
57 CORBA::Long theTimeStampNumber,
58 bool theIsMemoryCheck)
61 size_t aResult = TSuperClass::IsPossible(theResult,
68 VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName,
72 VISU::PField aField = anInput->GetField(theMeshName,
73 (VISU::TEntity)theEntity,
75 if(aField->myNbComp > 1)
78 }catch(std::exception& exc){
79 INFOS("Follow exception was occured :\n"<<exc.what());
81 INFOS("Unknown exception was occured!");
87 //---------------------------------------------------------------
88 int VISU::DeformedShape_i::myNbPresent = 0;
90 //---------------------------------------------------------------
95 return VISU::GenerateName("Def.Shape",myNbPresent++);
98 //---------------------------------------------------------------
99 const string VISU::DeformedShape_i::myComment = "DEFORMEDSHAPE";
101 //---------------------------------------------------------------
103 VISU::DeformedShape_i
106 return myComment.c_str();
110 //---------------------------------------------------------------
112 VISU::DeformedShape_i
116 return "ICON_TREE_DEFORMED_SHAPE";
118 return "ICON_TREE_DEFORMED_SHAPE_GROUPS";
122 //---------------------------------------------------------------
123 VISU::DeformedShape_i
124 ::DeformedShape_i(EPublishInStudyMode thePublishInStudyMode):
125 ColoredPrs3d_i(thePublishInStudyMode),
126 ScalarMap_i(thePublishInStudyMode),
127 MonoColorPrs_i(thePublishInStudyMode),
128 myDeformedShapePL(NULL)
130 if(MYDEBUG) MESSAGE("DeformedShape_i::DeformedShape_i");
134 //---------------------------------------------------------------
136 VISU::DeformedShape_i
137 ::SameAs(const Prs3d_i* theOrigin)
139 TSuperClass::SameAs(theOrigin);
141 if(const DeformedShape_i* aPrs3d = dynamic_cast<const DeformedShape_i*>(theOrigin)){
142 DeformedShape_i* anOrigin = const_cast<DeformedShape_i*>(aPrs3d);
143 SetColor(anOrigin->GetColor());
144 ShowColored(anOrigin->IsColored());
148 //---------------------------------------------------------------
150 VISU::DeformedShape_i
151 ::Create(const std::string& theMeshName,
152 VISU::Entity theEntity,
153 const std::string& theFieldName,
154 CORBA::Long theTimeStampNumber)
156 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
160 //---------------------------------------------------------------
162 VISU::DeformedShape_i
163 ::Restore(SALOMEDS::SObject_ptr theSObject,
164 const Storable::TRestoringMap& theMap)
166 if(!TSuperClass::Restore(theSObject, theMap))
169 SetScale(VISU::Storable::FindValue(theMap,"myFactor").toDouble());
175 //---------------------------------------------------------------
177 VISU::DeformedShape_i
178 ::ToStream(std::ostringstream& theStr)
180 TSuperClass::ToStream(theStr);
182 Storable::DataToStream( theStr, "myFactor", GetScale() );
186 //---------------------------------------------------------------
187 VISU::DeformedShape_i
190 if(MYDEBUG) MESSAGE("DeformedShape_i::~DeformedShape_i()");
194 //---------------------------------------------------------------
196 VISU::DeformedShape_i
197 ::SetScale(CORBA::Double theScale)
199 VISU::TSetModified aModified(this);
201 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedShapePL, vtkFloatingPointType>
202 (GetSpecificPL(), &VISU_DeformedShapePL::SetScale, theScale));
205 //---------------------------------------------------------------
207 VISU::DeformedShape_i
210 return myDeformedShapePL->GetScale();
214 //---------------------------------------------------------------
216 VISU::DeformedShape_i
217 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
220 myDeformedShapePL = VISU_DeformedShapePL::New();
222 myDeformedShapePL = dynamic_cast<VISU_DeformedShapePL*>(thePipeLine);
224 myDeformedShapePL->GetMapper()->SetScalarVisibility(IsColored());
226 TSuperClass::CreatePipeLine(myDeformedShapePL);
230 //---------------------------------------------------------------
232 VISU::DeformedShape_i
235 return IsPossible(GetCResult(),
239 GetTimeStampNumber(),
244 //---------------------------------------------------------------
246 VISU::DeformedShape_i
247 ::SetMapScale(double theMapScale)
249 VISU::TSetModified aModified(this);
251 myDeformedShapePL->SetMapScale(theMapScale);
255 //---------------------------------------------------------------
257 VISU::DeformedShape_i
258 ::CreateActor(bool toSupressShrinking)
260 VISU_Actor* anActor = TSuperClass::CreateActor(true);
261 anActor->SetVTKMapping(false);
262 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
263 int aDispMode = aResourceMgr->integerValue("VISU", "deformed_shape_represent", 1);
264 bool toShrink = aResourceMgr->booleanValue("VISU", "deformed_shape_shrink", false);
265 anActor->SetRepresentation(aDispMode);
266 if (toShrink && !toSupressShrinking) anActor->SetShrink();