1 // Copyright (C) 2007-2010 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
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_PrsObject_i.cxx
25 // Author : Alexey PETROV
28 #include "VISU_DeformedShape_i.hh"
29 #include "VISU_Prs3dUtils.hh"
30 #include "VISU_Result_i.hh"
32 #include "VISU_ScalarMapAct.h"
33 #include "VISU_DeformedShapePL.hxx"
34 #include "VISU_PipeLineUtils.hxx"
35 #include "VISU_Convertor.hxx"
37 #include "SUIT_ResourceMgr.h"
38 #include "SALOME_Event.h"
40 #include <vtkDataSetMapper.h>
41 #include <vtkProperty.h>
44 static int MYDEBUG = 0;
46 static int MYDEBUG = 0;
51 //---------------------------------------------------------------
54 ::IsPossible(Result_i* theResult,
55 const std::string& theMeshName,
56 VISU::Entity theEntity,
57 const std::string& theFieldName,
58 CORBA::Long theTimeStampNumber,
59 bool theIsMemoryCheck)
62 size_t aResult = TSuperClass::IsPossible(theResult,
69 VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName,
73 VISU::PField aField = anInput->GetField(theMeshName,
74 (VISU::TEntity)theEntity,
76 if(aField->myNbComp > 1)
79 }catch(std::exception& exc){
80 INFOS("Follow exception was occured :\n"<<exc.what());
82 INFOS("Unknown exception was occured!");
88 //---------------------------------------------------------------
89 int VISU::DeformedShape_i::myNbPresent = 0;
91 //---------------------------------------------------------------
96 return VISU::GenerateName("Def.Shape",myNbPresent++);
99 //---------------------------------------------------------------
100 const string VISU::DeformedShape_i::myComment = "DEFORMEDSHAPE";
102 //---------------------------------------------------------------
104 VISU::DeformedShape_i
107 return myComment.c_str();
111 //---------------------------------------------------------------
113 VISU::DeformedShape_i
117 return "ICON_TREE_DEFORMED_SHAPE";
119 return "ICON_TREE_DEFORMED_SHAPE_GROUPS";
123 //---------------------------------------------------------------
124 VISU::DeformedShape_i
125 ::DeformedShape_i(EPublishInStudyMode thePublishInStudyMode):
126 ColoredPrs3d_i(thePublishInStudyMode),
127 ScalarMap_i(thePublishInStudyMode),
128 MonoColorPrs_i(thePublishInStudyMode),
129 myDeformedShapePL(NULL)
131 if(MYDEBUG) MESSAGE("DeformedShape_i::DeformedShape_i");
135 //---------------------------------------------------------------
137 VISU::DeformedShape_i
138 ::SameAs(const Prs3d_i* theOrigin)
140 TSuperClass::SameAs(theOrigin);
142 if(const DeformedShape_i* aPrs3d = dynamic_cast<const DeformedShape_i*>(theOrigin)){
143 DeformedShape_i* anOrigin = const_cast<DeformedShape_i*>(aPrs3d);
144 SetColor(anOrigin->GetColor());
145 ShowColored(anOrigin->IsColored());
149 //---------------------------------------------------------------
151 VISU::DeformedShape_i
152 ::Create(const std::string& theMeshName,
153 VISU::Entity theEntity,
154 const std::string& theFieldName,
155 CORBA::Long theTimeStampNumber)
157 return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber);
161 //---------------------------------------------------------------
163 VISU::DeformedShape_i
164 ::Restore(SALOMEDS::SObject_ptr theSObject,
165 const Storable::TRestoringMap& theMap)
167 if(!TSuperClass::Restore(theSObject, theMap))
170 SetScale(VISU::Storable::FindValue(theMap,"myFactor").toDouble());
176 //---------------------------------------------------------------
178 VISU::DeformedShape_i
179 ::ToStream(std::ostringstream& theStr)
181 TSuperClass::ToStream(theStr);
183 Storable::DataToStream( theStr, "myFactor", GetScale() );
187 //---------------------------------------------------------------
188 VISU::DeformedShape_i
191 if(MYDEBUG) MESSAGE("DeformedShape_i::~DeformedShape_i()");
195 //---------------------------------------------------------------
197 VISU::DeformedShape_i
198 ::SetScale(CORBA::Double theScale)
200 VISU::TSetModified aModified(this);
202 ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformedShapePL, vtkFloatingPointType>
203 (GetSpecificPL(), &VISU_DeformedShapePL::SetScale, theScale));
206 //---------------------------------------------------------------
208 VISU::DeformedShape_i
211 return myDeformedShapePL->GetScale();
215 //---------------------------------------------------------------
217 VISU::DeformedShape_i
218 ::CreatePipeLine(VISU_PipeLine* thePipeLine)
221 myDeformedShapePL = VISU_DeformedShapePL::New();
223 myDeformedShapePL = dynamic_cast<VISU_DeformedShapePL*>(thePipeLine);
225 myDeformedShapePL->GetMapper()->SetScalarVisibility(IsColored());
227 TSuperClass::CreatePipeLine(myDeformedShapePL);
231 //---------------------------------------------------------------
233 VISU::DeformedShape_i
236 return IsPossible(GetCResult(),
240 GetTimeStampNumber(),
245 //---------------------------------------------------------------
247 VISU::DeformedShape_i
248 ::SetMapScale(double theMapScale)
250 VISU::TSetModified aModified(this);
252 myDeformedShapePL->SetMapScale(theMapScale);
256 //---------------------------------------------------------------
258 VISU::DeformedShape_i
259 ::CreateActor(bool toSupressShrinking)
261 VISU_Actor* anActor = TSuperClass::CreateActor(true);
262 anActor->SetVTKMapping(false);
263 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
264 int aDispMode = aResourceMgr->integerValue("VISU", "deformed_shape_represent", 1);
265 bool toShrink = aResourceMgr->booleanValue("VISU", "deformed_shape_shrink", false);
266 anActor->SetRepresentation(aDispMode);
267 if (toShrink && !toSupressShrinking) anActor->SetShrink();