X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FVISU_I%2FVISU_DeformedShape_i.cc;h=fa280ebf1af303c12ec38d2e2f48824a9e20a181;hb=1ffdb3278d27b8bc7761d45bf3822281f76e2dc4;hp=83f679ce03552b0a79252f047ada9e81046c6fa3;hpb=953451df51750a1d9910c0325f01d5ca7b6e0330;p=modules%2Fvisu.git diff --git a/src/VISU_I/VISU_DeformedShape_i.cc b/src/VISU_I/VISU_DeformedShape_i.cc index 83f679ce..fa280ebf 100644 --- a/src/VISU_I/VISU_DeformedShape_i.cc +++ b/src/VISU_I/VISU_DeformedShape_i.cc @@ -1,55 +1,80 @@ -// VISU OBJECT : interactive object for VISU entities implementation +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// VISU OBJECT : interactive object for VISU entities implementation // File : VISU_PrsObject_i.cxx // Author : Alexey PETROV // Module : VISU - +// #include "VISU_DeformedShape_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_Result_i.hh" #include "VISU_ScalarMapAct.h" #include "VISU_DeformedShapePL.hxx" +#include "VISU_PipeLineUtils.hxx" #include "VISU_Convertor.hxx" +#include "SUIT_ResourceMgr.h" +#include "SALOME_Event.h" + #include #include -using namespace VISU; -using namespace std; - #ifdef _DEBUG_ static int MYDEBUG = 0; #else static int MYDEBUG = 0; #endif -int VISU::DeformedShape_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, int theIteration, int isMemoryCheck) +using namespace std; + +//--------------------------------------------------------------- +size_t +VISU::DeformedShape_i +::IsPossible(Result_i* theResult, + const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber, + bool theIsMemoryCheck) { try{ - if(!VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,isMemoryCheck)) return 0; - const VISU::PField aField = theResult->GetInput()->GetField(theMeshName,(VISU::TEntity)theEntity,theFieldName); - return aField->myNbComp > 1; + size_t aResult = TSuperClass::IsPossible(theResult, + theMeshName, + theEntity, + theFieldName, + theTimeStampNumber, + theIsMemoryCheck); + if(aResult){ + VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); + VISU::PField aField = anInput->GetField(theMeshName, + (VISU::TEntity)theEntity, + theFieldName); + if(aField->myNbComp > 1) + return aResult; + } }catch(std::exception& exc){ INFOS("Follow exception was occured :\n"<GetStudyDocument()), - Prs3d_i(theResult,theAddToStudy), - ColoredPrs3d_i(theResult,theAddToStudy), - ScalarMap_i(theResult,theAddToStudy), - myDeformedShapePL(NULL) + +//--------------------------------------------------------------- +const char* +VISU::DeformedShape_i +::GetIconName() { - if(MYDEBUG) MESSAGE("DeformedShape_i::DeformedShape_i"); -} + if (!IsGroupsUsed()) + return "ICON_TREE_DEFORMED_SHAPE"; + else + return "ICON_TREE_DEFORMED_SHAPE_GROUPS"; +} -VISU::DeformedShape_i:: -DeformedShape_i(Result_i* theResult, - SALOMEDS::SObject_ptr theSObject) : - PrsObject_i(theResult->GetStudyDocument()), - Prs3d_i(theResult,theSObject), - ColoredPrs3d_i(theResult,theSObject), - ScalarMap_i(theResult,theSObject), +//--------------------------------------------------------------- +VISU::DeformedShape_i +::DeformedShape_i(EPublishInStudyMode thePublishInStudyMode): + ColoredPrs3d_i(thePublishInStudyMode), + ScalarMap_i(thePublishInStudyMode), + MonoColorPrs_i(thePublishInStudyMode), myDeformedShapePL(NULL) { if(MYDEBUG) MESSAGE("DeformedShape_i::DeformedShape_i"); } -void VISU::DeformedShape_i::SameAs(const Prs3d_i* theOrigin) +//--------------------------------------------------------------- +void +VISU::DeformedShape_i +::SameAs(const Prs3d_i* theOrigin) { TSuperClass::SameAs(theOrigin); @@ -102,91 +145,126 @@ void VISU::DeformedShape_i::SameAs(const Prs3d_i* theOrigin) } } - -VISU::Storable* VISU::DeformedShape_i::Create(const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, int theIteration) +//--------------------------------------------------------------- +VISU::Storable* +VISU::DeformedShape_i +::Create(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber) { - myIsColored = false; - myColor.R = myColor.G = myColor.B = 0.5; - return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration); + return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber); } -VISU::Storable* VISU::DeformedShape_i::Restore(const Storable::TRestoringMap& theMap) +//--------------------------------------------------------------- +VISU::Storable* +VISU::DeformedShape_i +::Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap) { - TSuperClass::Restore(theMap); + if(!TSuperClass::Restore(theSObject, theMap)) + return NULL; SetScale(VISU::Storable::FindValue(theMap,"myFactor").toDouble()); - myIsColored = VISU::Storable::FindValue(theMap,"myIsColored").toInt(); - myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble(); - myColor.G = VISU::Storable::FindValue(theMap,"myColor.G").toDouble(); - myColor.B = VISU::Storable::FindValue(theMap,"myColor.B").toDouble(); return this; } -void VISU::DeformedShape_i::ToStream(std::ostringstream& theStr){ - ScalarMap_i::ToStream(theStr); +//--------------------------------------------------------------- +void +VISU::DeformedShape_i +::ToStream(std::ostringstream& theStr) +{ + TSuperClass::ToStream(theStr); Storable::DataToStream( theStr, "myFactor", GetScale() ); - - Storable::DataToStream( theStr, "myIsColored", myIsColored ); - Storable::DataToStream( theStr, "myColor.R", myColor.R ); - Storable::DataToStream( theStr, "myColor.G", myColor.G ); - Storable::DataToStream( theStr, "myColor.B", myColor.B ); } -VISU::DeformedShape_i::~DeformedShape_i(){ +//--------------------------------------------------------------- +VISU::DeformedShape_i +::~DeformedShape_i() +{ if(MYDEBUG) MESSAGE("DeformedShape_i::~DeformedShape_i()"); } -void VISU::DeformedShape_i::SetScale(CORBA::Double theScale) { - myDeformedShapePL->SetScale(theScale); +//--------------------------------------------------------------- +void +VISU::DeformedShape_i +::SetScale(CORBA::Double theScale) +{ + VISU::TSetModified aModified(this); + + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificPL(), &VISU_DeformedShapePL::SetScale, theScale)); } -CORBA::Double VISU::DeformedShape_i::GetScale(){ + +//--------------------------------------------------------------- +CORBA::Double +VISU::DeformedShape_i +::GetScale() +{ return myDeformedShapePL->GetScale(); } -void VISU::DeformedShape_i::DoHook(){ - if(!myPipeLine) myPipeLine = VISU_DeformedShapePL::New(); - myDeformedShapePL = dynamic_cast(myPipeLine); - myPipeLine->GetMapper()->SetScalarVisibility(IsColored()); +//--------------------------------------------------------------- +void +VISU::DeformedShape_i +::CreatePipeLine(VISU_PipeLine* thePipeLine) +{ + if(!thePipeLine){ + myDeformedShapePL = VISU_DeformedShapePL::New(); + }else + myDeformedShapePL = dynamic_cast(thePipeLine); - ScalarMap_i::DoHook(); + myDeformedShapePL->GetMapper()->SetScalarVisibility(IsColored()); + + TSuperClass::CreatePipeLine(myDeformedShapePL); } -void VISU::DeformedShape_i::SetMapScale(double theMapScale){ +//--------------------------------------------------------------- +bool +VISU::DeformedShape_i +::CheckIsPossible() +{ + return IsPossible(GetCResult(), + GetCMeshName(), + GetEntity(), + GetCFieldName(), + GetTimeStampNumber(), + true); +} + + +//--------------------------------------------------------------- +void +VISU::DeformedShape_i +::SetMapScale(double theMapScale) +{ + VISU::TSetModified aModified(this); + myDeformedShapePL->SetMapScale(theMapScale); } +//--------------------------------------------------------------- VISU_Actor* VISU::DeformedShape_i -::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) +::CreateActor(bool toSupressShrinking) { - VISU_Actor* anActor = VISU::ScalarMap_i::CreateActor(theIO); - anActor->SetRepresentation(1); - anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B); + VISU_Actor* anActor = TSuperClass::CreateActor(true); anActor->SetVTKMapping(false); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + int aDispMode = aResourceMgr->integerValue("VISU", "deformed_shape_represent", 1); + bool toShrink = aResourceMgr->booleanValue("VISU", "deformed_shape_shrink", false); + anActor->SetRepresentation(aDispMode); + if (toShrink && !toSupressShrinking) anActor->SetShrink(); return anActor; } -void VISU::DeformedShape_i::UpdateActor(VISU_Actor* theActor) { - if(VISU_ScalarMapAct* anActor = dynamic_cast(theActor)){ - if(IsColored()){ - anActor->SetBarVisibility(true); - myPipeLine->GetMapper()->SetScalarVisibility(1); - }else{ - anActor->SetBarVisibility(false); - myPipeLine->GetMapper()->SetScalarVisibility(0); - anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B); - } - VISU::ScalarMap_i::UpdateActor(theActor); - } -}