X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVISU_I%2FVISU_Vectors_i.cc;h=d2d4cfd345029695e0608d035fafcddcf080325e;hb=1ffdb3278d27b8bc7761d45bf3822281f76e2dc4;hp=1ab9c2549a4970939ee0140343d0d10caa6ae874;hpb=e967b0415406f4f86ca2c9489abc8554b4c15dae;p=modules%2Fvisu.git diff --git a/src/VISU_I/VISU_Vectors_i.cc b/src/VISU_I/VISU_Vectors_i.cc index 1ab9c254..d2d4cfd3 100644 --- a/src/VISU_I/VISU_Vectors_i.cc +++ b/src/VISU_I/VISU_Vectors_i.cc @@ -1,43 +1,43 @@ -// 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. // -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// VISU OBJECT : interactive object for VISU entities implementation // File : VISU_Vectors_i.cc // Author : Alexey PETROV // Module : VISU - +// #include "VISU_Vectors_i.hh" +#include "VISU_Prs3dUtils.hh" #include "VISU_Result_i.hh" #include "VISU_VectorsAct.h" #include "VISU_VectorsPL.hxx" +#include "VISU_PipeLineUtils.hxx" #include "VISU_Convertor.hxx" #include "SUIT_ResourceMgr.h" +#include "SALOME_Event.h" #include -using namespace VISU; -using namespace std; - #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -46,62 +46,101 @@ static int MYDEBUG = 0; static int INCMEMORY = 4+12; -int VISU::Vectors_i::IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, int theIteration, int isMemoryCheck) +using namespace std; + +//--------------------------------------------------------------- +size_t +VISU::Vectors_i +::IsPossible(Result_i* theResult, + const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber, + bool theIsMemoryCheck) { - bool aResult = false; try{ - aResult = DeformedShape_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theIteration,false); - if(isMemoryCheck && aResult){ - float aSize = INCMEMORY* - theResult->GetInput()->GetTimeStampSize(theMeshName,(VISU::TEntity)theEntity,theFieldName,theIteration); + size_t aResult = TSuperClass::IsPossible(theResult, + theMeshName, + theEntity, + theFieldName, + theTimeStampNumber, + false); + if(theIsMemoryCheck && aResult){ + bool anIsEstimated = true; + VISU::Result_i::PInput anInput = theResult->GetInput(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); + size_t aSize = anInput->GetTimeStampOnMeshSize(theMeshName, + (VISU::TEntity)theEntity, + theFieldName, + theTimeStampNumber, + anIsEstimated); + if(anIsEstimated) + aSize *= INCMEMORY; aResult = VISU_PipeLine::CheckAvailableMemory(aSize); - MESSAGE("Vectors_i::IsPossible - CheckAvailableMemory = "<GetStudyDocument()), - Prs3d_i(theResult,theAddToStudy), - ColoredPrs3d_i(theResult,theAddToStudy), - ScalarMap_i(theResult,theAddToStudy), - DeformedShape_i(theResult,theAddToStudy), - myVectorsPL(NULL) +//--------------------------------------------------------------- +const char* +VISU::Vectors_i +::GetComment() const { + return myComment.c_str(); } -VISU::Vectors_i:: -Vectors_i(Result_i* theResult, - SALOMEDS::SObject_ptr theSObject) : - PrsObject_i(theResult->GetStudyDocument()), - Prs3d_i(theResult,theSObject), - ColoredPrs3d_i(theResult,theSObject), - ScalarMap_i(theResult,theSObject), - DeformedShape_i(theResult,theSObject), - myVectorsPL(NULL) +//--------------------------------------------------------------- +const char* +VISU::Vectors_i +::GetIconName() { + if (!IsGroupsUsed()) + return "ICON_TREE_VECTORS"; + else + return "ICON_TREE_VECTORS_GROUPS"; } +//--------------------------------------------------------------- +VISU::Vectors_i +::Vectors_i(EPublishInStudyMode thePublishInStudyMode) : + ColoredPrs3d_i(thePublishInStudyMode), + ScalarMap_i(thePublishInStudyMode), + MonoColorPrs_i(thePublishInStudyMode), + DeformedShape_i(thePublishInStudyMode), + myLineWidth(1.0), + myVectorsPL(NULL) +{} + -void VISU::Vectors_i::SameAs(const VISU::Prs3d_i* theOrigin) +//--------------------------------------------------------------- +void +VISU::Vectors_i +::SameAs(const VISU::Prs3d_i* theOrigin) { TSuperClass::SameAs(theOrigin); @@ -112,17 +151,26 @@ void VISU::Vectors_i::SameAs(const VISU::Prs3d_i* theOrigin) } -VISU::Storable* VISU::Vectors_i::Create(const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, int theIteration) +//--------------------------------------------------------------- +VISU::Storable* +VISU::Vectors_i +::Create(const std::string& theMeshName, + VISU::Entity theEntity, + const std::string& theFieldName, + CORBA::Long theTimeStampNumber) { - myLineWidth = 1.0; - return DeformedShape_i::Create(theMeshName,theEntity,theFieldName,theIteration); + return TSuperClass::Create(theMeshName,theEntity,theFieldName,theTimeStampNumber); } -VISU::Storable* VISU::Vectors_i::Restore(const Storable::TRestoringMap& theMap) +//--------------------------------------------------------------- +VISU::Storable* +VISU::Vectors_i +::Restore(SALOMEDS::SObject_ptr theSObject, + const Storable::TRestoringMap& theMap) { - TSuperClass::Restore(theMap); + if(!TSuperClass::Restore(theSObject, theMap)) + return NULL; SetGlyphType(VISU::Vectors::GlyphType(VISU::Storable::FindValue(theMap,"myTypeGlyph").toInt())); SetGlyphPos(VISU::Vectors::GlyphPos(VISU::Storable::FindValue(theMap,"myPosGlyph").toInt())); @@ -132,8 +180,12 @@ VISU::Storable* VISU::Vectors_i::Restore(const Storable::TRestoringMap& theMap) } -void VISU::Vectors_i::ToStream(std::ostringstream& theStr){ - DeformedShape_i::ToStream(theStr); +//--------------------------------------------------------------- +void +VISU::Vectors_i +::ToStream(std::ostringstream& theStr) +{ + TSuperClass::ToStream(theStr); Storable::DataToStream( theStr, "myTypeGlyph", int(GetGlyphType())); Storable::DataToStream( theStr, "myPosGlyph", int(GetGlyphPos())); @@ -141,64 +193,126 @@ void VISU::Vectors_i::ToStream(std::ostringstream& theStr){ } -VISU::Vectors_i::~Vectors_i(){ +//--------------------------------------------------------------- +VISU::Vectors_i +::~Vectors_i() +{ if(MYDEBUG) MESSAGE("Vectors_i::~Vectors_i()"); } -void VISU::Vectors_i::SetLineWidth(CORBA::Double theWidth) { +//--------------------------------------------------------------- +void +VISU::Vectors_i +::SetLineWidth(CORBA::Double theWidth) +{ + if(VISU::CheckIsSameValue(myLineWidth, theWidth)) + return; + + VISU::TSetModified aModified(this); + myLineWidth = theWidth; + myParamsTime.Modified(); } -CORBA::Double VISU::Vectors_i::GetLineWidth() { + +//--------------------------------------------------------------- +CORBA::Double +VISU::Vectors_i +::GetLineWidth() +{ return myLineWidth; } -void VISU::Vectors_i::SetGlyphType(VISU::Vectors::GlyphType theType) { - myVectorsPL->SetGlyphType(VISU_VectorsPL::GlyphType(theType)); +//--------------------------------------------------------------- +void +VISU::Vectors_i +::SetGlyphType(VISU::Vectors::GlyphType theType) +{ + VISU::TSetModified aModified(this); + + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificPL(), &VISU_VectorsPL::SetGlyphType, VISU_VectorsPL::GlyphType(theType))); } -VISU::Vectors::GlyphType VISU::Vectors_i::GetGlyphType() { + +//--------------------------------------------------------------- +VISU::Vectors::GlyphType +VISU::Vectors_i +::GetGlyphType() +{ return VISU::Vectors::GlyphType(myVectorsPL->GetGlyphType()); } -void VISU::Vectors_i::SetGlyphPos(VISU::Vectors::GlyphPos thePos) { - myVectorsPL->SetGlyphPos(VISU_VectorsPL::GlyphPos(thePos)); +//--------------------------------------------------------------- +void +VISU::Vectors_i +::SetGlyphPos(VISU::Vectors::GlyphPos thePos) +{ + VISU::TSetModified aModified(this); + + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificPL(), &VISU_VectorsPL::SetGlyphPos, VISU_VectorsPL::GlyphPos(thePos))); } -VISU::Vectors::GlyphPos VISU::Vectors_i::GetGlyphPos() { + +//--------------------------------------------------------------- +VISU::Vectors::GlyphPos +VISU::Vectors_i::GetGlyphPos() +{ return VISU::Vectors::GlyphPos(myVectorsPL->GetGlyphPos()); } -void VISU::Vectors_i::DoHook(){ - if(!myPipeLine) myPipeLine = VISU_VectorsPL::New(); - myVectorsPL = dynamic_cast(myPipeLine); +//--------------------------------------------------------------- +void +VISU::Vectors_i +::CreatePipeLine(VISU_PipeLine* thePipeLine) +{ + if(!thePipeLine){ + myVectorsPL = VISU_VectorsPL::New(); + }else + myVectorsPL = dynamic_cast(thePipeLine); - DeformedShape_i::DoHook(); + TSuperClass::CreatePipeLine(myVectorsPL); } -VISU_PipeLine* VISU::Vectors_i::GetPipeLine(){ +//--------------------------------------------------------------- +VISU_PipeLine* +VISU::Vectors_i +::GetActorPipeLine() +{ VISU_PipeLine* aPipeLine = VISU_VectorsPL::New(); - aPipeLine->SetIDMapper(myPipeLine->GetIDMapper()); - aPipeLine->ShallowCopy(myPipeLine); - aPipeLine->Update(); + aPipeLine->ShallowCopy(GetPipeLine(), true); return aPipeLine; } -VISU_Actor* VISU::Vectors_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) +//--------------------------------------------------------------- +bool +VISU::Vectors_i +::CheckIsPossible() +{ + return IsPossible(GetCResult(),GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber(),true); +} + +//--------------------------------------------------------------- +VISU_Actor* +VISU::Vectors_i +::CreateActor() { VISU_VectorsAct* anActor = VISU_VectorsAct::New(); try{ - VISU::Prs3d_i::CreateActor(anActor,theIO); + VISU::Prs3d_i::CreateActor(anActor); anActor->SetVTKMapping(true); anActor->SetBarVisibility(true); anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B); anActor->GetProperty()->SetLineWidth(GetLineWidth()); SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); int aDispMode = aResourceMgr->integerValue("VISU", "vectors_represent", 1); + bool toUseShading = aResourceMgr->booleanValue("VISU", "represent_shading", false); anActor->SetRepresentation(aDispMode); + anActor->SetShading(toUseShading); UpdateActor(anActor); }catch(...){ anActor->Delete(); @@ -208,12 +322,16 @@ VISU_Actor* VISU::Vectors_i::CreateActor(const Handle(SALOME_InteractiveObject)& } -void VISU::Vectors_i::UpdateActor(VISU_Actor* theActor) { +//--------------------------------------------------------------- +void +VISU::Vectors_i +::UpdateActor(VISU_ActorBase* theActor) +{ if(VISU_VectorsAct* anActor = dynamic_cast(theActor)){ - VISU::DeformedShape_i::UpdateActor(anActor); + TSuperClass::UpdateActor(anActor); anActor->GetProperty()->SetLineWidth(GetLineWidth()); if(VISU_VectorsPL* aVectorsPL = dynamic_cast(anActor->GetPipeLine())){ - aVectorsPL->ShallowCopy(myPipeLine); + aVectorsPL->ShallowCopy(GetPipeLine(), true); aVectorsPL->Update(); aVectorsPL->SetMapScale(myVectorsPL->GetMapScale()); }