From: apo Date: Wed, 19 Sep 2007 12:41:10 +0000 (+0000) Subject: Fix for Bug NPAL16764 - EDF 553 VISU : X-Git-Tag: T_24092007~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8f45a269ebce1ff29f22aff6a1cfee0bf9db7fdb;p=modules%2Fvisu.git Fix for Bug NPAL16764 - EDF 553 VISU : In Animation Bad range by default in Scalarmap The bug is fixed by introduction a special TMinMaxController interface which can be applied to a VISU colored 3D presentations. --- diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index dad85109..63352d3a 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -788,9 +788,9 @@ namespace template void InitDiloglgFromPrsObject(TDialog* theDialog, - FieldData& theData) + TPrs3d* thePrs3d) { - theDialog->initFromPrsObject(dynamic_cast(theData.myPrs[0])); + theDialog->initFromPrsObject(thePrs3d); } @@ -798,9 +798,9 @@ namespace void InitDiloglgFromPrsObject (VisuGUI_ScalarMapOnDeformedShapeDlg* theDialog, - FieldData& theData) + VISU::ScalarMapOnDeformedShape_i* thePrs3d) { - theDialog->initFromPrsObject(dynamic_cast(theData.myPrs[0]), true); + theDialog->initFromPrsObject(thePrs3d, true); } @@ -811,25 +811,34 @@ namespace VISU_TimeAnimation* theAnimator) { TDialog* aDlg = new TDialog(theModule); - InitDiloglgFromPrsObject(aDlg, theData); + TPrs3d* aPrs3d = dynamic_cast(theData.myPrs[0]); + InitDiloglgFromPrsObject(aDlg, aPrs3d); if (aDlg->exec()) { - aDlg->storeToPrsObject(dynamic_cast(theData.myPrs[0])); - for (int i = 1; i < theData.myNbFrames; i++) - theData.myPrs[i]->SameAsParams(theData.myPrs[0], - theData.myPrs[i]->GetMeshName(), - theData.myPrs[i]->GetFieldName(), - theData.myPrs[i]->GetEntity(), - theData.myPrs[i]->GetIteration(), - true); - if ( theAnimator->getAnimationMode() == 1 ) { - for (int i = 1; i < theAnimator->getNbFields(); i++) { - for (int j = 0; j < theAnimator->getFieldData(i).myNbFrames; j++) - theAnimator->getFieldData(i).myPrs[j]->SameAsParams(theData.myPrs[0], - theData.myPrs[j]->GetMeshName(), - theData.myPrs[j]->GetFieldName(), - theData.myPrs[j]->GetEntity(), - theData.myPrs[j]->GetIteration(), - true); + aDlg->storeToPrsObject(dynamic_cast(aPrs3d)); + for (long aFrameId = 1; aFrameId < theData.myNbFrames; aFrameId++){ + VISU::ColoredPrs3d_i* aColoredPrs3d = theData.myPrs[aFrameId]; + aColoredPrs3d->SameAsParams(aPrs3d, + aColoredPrs3d->GetMeshName(), + aColoredPrs3d->GetFieldName(), + aColoredPrs3d->GetEntity(), + aColoredPrs3d->GetIteration(), + true); + } + + if ( theAnimator->getAnimationMode() == VISU::Animation::SUCCCESSIVE ) { + for (int aFieldId = 1; aFieldId < theAnimator->getNbFields(); aFieldId++) { + FieldData& aFieldData = theAnimator->getFieldData(aFieldId); + for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) { + VISU::ColoredPrs3d_i* aColoredPrs3d = aFieldData.myPrs[aFrameId]; + CORBA::String_var aTitle = aColoredPrs3d->GetTitle(); + aColoredPrs3d->SameAsParams(aPrs3d, + aColoredPrs3d->GetMeshName(), + aColoredPrs3d->GetFieldName(), + aColoredPrs3d->GetEntity(), + aColoredPrs3d->GetIteration(), + true); + aColoredPrs3d->SetTitle(aTitle); + } } } } diff --git a/src/VISU_I/Makefile.in b/src/VISU_I/Makefile.in index c59e0540..df26fa84 100644 --- a/src/VISU_I/Makefile.in +++ b/src/VISU_I/Makefile.in @@ -56,7 +56,8 @@ LIB_SRC = \ VISU_CorbaMedConvertor.cxx \ VISU_DumpPython.cc \ VISU_ScalarMapOnDeformedShape_i.cc \ - VISU_PrsMerger_i.cc + VISU_PrsMerger_i.cc \ + SALOME_GenericObjPointer.cc LIB_MOC = \ VISU_TimeAnimation.h @@ -103,7 +104,8 @@ EXPORT_HEADERS = \ VISU_View_i.hh \ VISU_TimeAnimation.h \ VISU_ScalarMapOnDeformedShape_i.hh \ - VISU_PrsMerger_i.hh + VISU_PrsMerger_i.hh \ + SALOME_GenericObjPointer.hh # additionnal information to compil and link file CPPFLAGS += \ diff --git a/src/VISU_I/SALOME_GenericObjPointer.cc b/src/VISU_I/SALOME_GenericObjPointer.cc new file mode 100644 index 00000000..1e774e1e --- /dev/null +++ b/src/VISU_I/SALOME_GenericObjPointer.cc @@ -0,0 +1,25 @@ +// 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 +// +// +// File : SALOME_GenericObjPtr.cc +// Author : Oleg UVAROV +// Module : SALOME + +#include "SALOME_GenericObjPointer.hh" diff --git a/src/VISU_I/SALOME_GenericObjPointer.hh b/src/VISU_I/SALOME_GenericObjPointer.hh new file mode 100644 index 00000000..5492b595 --- /dev/null +++ b/src/VISU_I/SALOME_GenericObjPointer.hh @@ -0,0 +1,216 @@ +// 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 +// +// +// File : SALOME_GenericObjPtr.hh +// Author : Oleg UVAROV +// Module : SALOME + +#ifndef SALOME_GenericObjPointer_HH +#define SALOME_GenericObjPointer_HH + +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SALOME_GenericObj) + +#include // for std::basic_ostream + +namespace SALOME +{ + //---------------------------------------------------------------------------- + template + class GenericObjPtr + { + //! Pointer to the actual object. + TGenericObj* myPointer; + + void + swap(GenericObjPtr& thePointer) + { + TGenericObj* aPointer = thePointer.myPointer; + thePointer.myPointer = this->myPointer; + this->myPointer = aPointer; + } + + void + Register() + { + if(this->myPointer) + this->myPointer->Register(); + } + + void + Destroy() + { + if(this->myPointer){ + this->myPointer->Destroy(); + this->myPointer = NULL; + } + } + + public: + //! Initialize smart pointer to NULL. + GenericObjPtr(): + myPointer(NULL) + {} + + //! Initialize smart pointer to given object (TSGenericObj must be complete). + template + explicit + GenericObjPtr(TGenObj* thePointer): + myPointer(thePointer) + { + this->Register(); + } + + /*! + Initialize smart pointer with a new reference to the same object + referenced by given smart pointer. + */ + GenericObjPtr(const GenericObjPtr& thePointer): + myPointer(thePointer.myPointer) + { + this->Register(); + } + + /*! + Initialize smart pointer with a new reference to the same object + referenced by given smart pointer. + */ + template + GenericObjPtr(const GenericObjPtr& thePointer): + myPointer(thePointer.get()) + { + this->Register(); + } + + //! Destroy smart pointer and remove the reference to its object. + ~GenericObjPtr() + { + this->Destroy(); + } + + /*! + Assign object to reference. This removes any reference to an old + object. + */ + template + GenericObjPtr& + operator=(TGenObj* thePointer) + { + GenericObjPtr aTmp(thePointer); + aTmp.swap(*this); + return *this; + } + + /*! + Assign object to reference. This removes any reference to an old + object. + */ + GenericObjPtr& + operator=(const GenericObjPtr& thePointer) + { + GenericObjPtr aTmp(thePointer); + aTmp.swap(*this); + return *this; + } + + /*! + Assign object to reference. This removes any reference to an old + object. + */ + template + GenericObjPtr& + operator=(const GenericObjPtr& thePointer) + { + GenericObjPtr aTmp(thePointer); + aTmp.swap(*this); + return *this; + } + + //! Get the contained pointer. + virtual + TGenericObj* + get() const + { + return this->myPointer; + } + + //! Get the contained pointer. + operator TGenericObj* () const + { + return this->get(); + } + + /*! + Dereference the pointer and return a reference to the contained + object. + */ + TGenericObj& + operator*() const + { + return *this->get(); + } + + //! Provides normal pointer target member access using operator ->. + TGenericObj* operator->() const + { + return this->get(); + } + + operator bool () const + { + return this->get() != 0; + } + }; +} + +template +inline +bool +operator<(SALOME::GenericObjPtr const & a, SALOME::GenericObjPtr const & b) +{ + return a.get() < b.get(); +} + +template +inline +bool +operator==(SALOME::GenericObjPtr const & a, SALOME::GenericObjPtr const & b) +{ + return a.get() == b.get(); +} + +template +inline +bool +operator!=(SALOME::GenericObjPtr const & a, SALOME::GenericObjPtr const & b) +{ + return a.get() != b.get(); +} + +template +std::ostream& +operator<< (std::ostream & os, SALOME::GenericObjPtr const & p) +{ + os << p.get(); + return os; +} + + +#endif diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 02f5ce66..b0da6dab 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -46,6 +46,72 @@ static int MYDEBUG = 0; #endif +namespace VISU +{ + //--------------------------------------------------------------- + vtkFloatingPointType + TMinMaxController + ::GetComponentMin(vtkIdType theCompID) + { + return VTK_LARGE_FLOAT; + } + + + //--------------------------------------------------------------- + vtkFloatingPointType + TMinMaxController + ::GetComponentMax(vtkIdType theCompID) + { + return -VTK_LARGE_FLOAT; + } + + + //--------------------------------------------------------------- + struct TSimpleMinMaxController: virtual TVTKMinMaxController + { + VISU::PField myField; + + TSimpleMinMaxController(VISU::PField theField) + { + myField = theField; + } + + virtual + vtkFloatingPointType + GetComponentMin(vtkIdType theCompID) + { + if(myField){ + TMinMax aMinMax = myField->GetMinMax(theCompID); + return aMinMax.first; + } + return TMinMaxController::GetComponentMin(theCompID); + } + + virtual + vtkFloatingPointType + GetComponentMax(vtkIdType theCompID) + { + if(myField){ + TMinMax aMinMax = myField->GetMinMax(theCompID); + return aMinMax.second; + } + return TMinMaxController::GetComponentMax(theCompID); + } + }; + + + //--------------------------------------------------------------- + PMinMaxController + CreateDefaultMinMaxController(VISU::ColoredPrs3d_i* theColoredPrs3d) + { + PField aField = theColoredPrs3d->GetField(); + return PMinMaxController(new TSimpleMinMaxController(aField)); + } + + + //--------------------------------------------------------------- +} + //============================================================================ VISU::ColoredPrs3d_i:: ColoredPrs3d_i(Result_i* theResult, @@ -65,10 +131,27 @@ ColoredPrs3d_i(Result_i* theResult, myIsFixedRange(false) {} +//--------------------------------------------------------------- VISU::ColoredPrs3d_i ::~ColoredPrs3d_i() {} +//--------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::Register() +{ + TSuperClass::Register(); +} + +//--------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::Destroy() +{ + TSuperClass::Destroy(); +} + //--------------------------------------------------------------- void VISU::ColoredPrs3d_i @@ -119,6 +202,13 @@ VISU::ColoredPrs3d_i SetNbColors(anOrigin->GetNbColors()); SetBarOrientation(anOrigin->GetBarOrientation()); + SetMinMaxController(anOrigin->GetMinMaxController()); + + if(anOrigin->IsRangeFixed()) + SetRange(anOrigin->GetMin(), anOrigin->GetMax()); + else + SetSourceRange(); + SetPosition(anOrigin->GetPosX(), anOrigin->GetPosY()); SetSize(anOrigin->GetWidth(), anOrigin->GetHeight()); SetLabels(anOrigin->GetLabels()); @@ -197,6 +287,94 @@ VISU::ColoredPrs3d_i return myScalarMapPL->GetScalarRange()[1]; } +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::SetRange(CORBA::Double theMin, CORBA::Double theMax) +{ + vtkFloatingPointType aScalarRange[2] = {theMin, theMax}; + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetScalarMapPL(), &VISU_ScalarMapPL::SetScalarRange, aScalarRange)); + + myIsFixedRange = true; +} + +//---------------------------------------------------------------------------- +bool +VISU::ColoredPrs3d_i +::IsRangeFixed() +{ + return myIsFixedRange; +} + +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::SetSourceRange() +{ + if(IsTimeStampFixed()){ + ProcessVoidEvent(new TVoidMemFunEvent + (myScalarMapPL, &VISU_ScalarMapPL::SetSourceRange)); + }else{ + vtkFloatingPointType aScalarRange[2] = {GetSourceMin(), GetSourceMax()}; + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myScalarMapPL, &VISU_ScalarMapPL::SetScalarRange, aScalarRange)); + } + + myIsFixedRange = false; +} + +//---------------------------------------------------------------------------- +CORBA::Double +VISU::ColoredPrs3d_i +::GetSourceMin() +{ + if(IsTimeStampFixed()){ + vtkFloatingPointType aRange[2]; + GetScalarMapPL()->GetSourceRange(aRange); + return aRange[0]; + } + return GetComponentMin(GetScalarMode()); +} + +//---------------------------------------------------------------------------- +CORBA::Double +VISU::ColoredPrs3d_i +::GetSourceMax() +{ + if(IsTimeStampFixed()){ + vtkFloatingPointType aRange[2]; + GetScalarMapPL()->GetSourceRange(aRange); + return aRange[1]; + } + return GetComponentMax(GetScalarMode()); +} + +//---------------------------------------------------------------------------- +vtkFloatingPointType +VISU::ColoredPrs3d_i +::GetComponentMin(vtkIdType theCompID) +{ + if(PMinMaxController aMinMaxController = GetMinMaxController()) + return aMinMaxController->GetComponentMin(theCompID); + + TMinMax aTMinMax = GetField()->GetMinMax(theCompID); + return aTMinMax.first; +} + +//---------------------------------------------------------------------------- +vtkFloatingPointType +VISU::ColoredPrs3d_i +::GetComponentMax(vtkIdType theCompID) +{ + if(PMinMaxController aMinMaxController = GetMinMaxController()) + return aMinMaxController->GetComponentMax(theCompID); + + TMinMax aTMinMax = GetField()->GetMinMax(theCompID); + return aTMinMax.second; +} + +//---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i ::SetNbColors(CORBA::Long theNbColors) @@ -727,8 +905,10 @@ VISU::ColoredPrs3d_i QString aComment; myName = "NoName"; if(theRestoring <= 0){ - if(theRestoring == 0) myScalarMapPL->Init(); - if(!myIsFixedRange) myScalarMapPL->SetSourceRange(); + if(theRestoring == 0) + myScalarMapPL->Init(); + if(!myIsFixedRange) + myScalarMapPL->SetSourceRange(); const VISU::TValField& aValField = myField->myValField; const VISU::PValForTime aValForTime = aValField.find(myIteration)->second; aComment.sprintf("%s %s",myFieldName.c_str(),VISU_Convertor::GenerateName(aValForTime->myTime).c_str()); @@ -782,6 +962,8 @@ VISU::ColoredPrs3d_i return myField; } + +//---------------------------------------------------------------------------- CORBA::Boolean VISU::ColoredPrs3d_i ::IsTimeStampFixed() @@ -790,6 +972,29 @@ VISU::ColoredPrs3d_i return !CORBA::is_nil(aSObject); } + +//---------------------------------------------------------------------------- +VISU::PMinMaxController +VISU::ColoredPrs3d_i +::GetMinMaxController() +{ + return myMinMaxController; +} + + +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::SetMinMaxController(const VISU::PMinMaxController& theController) +{ + myMinMaxController = theController; + + if(!IsRangeFixed()) + SetSourceRange(); +} + + +//---------------------------------------------------------------------------- const std::string& VISU::ColoredPrs3d_i ::GetMeshName() const diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 0fd4e6d1..9bcc7ea8 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -28,13 +28,64 @@ #define VISU_ColoredPrs3d_i_HeaderFile #include "VISU_Prs3d_i.hh" +#include "SALOME_GenericObjPointer.hh" class VISU_ScalarMapPL; namespace VISU { + //---------------------------------------------------------------------------- + struct TMinMaxController + { + virtual + vtkFloatingPointType + GetComponentMin(vtkIdType theCompID); + + virtual + vtkFloatingPointType + GetComponentMax(vtkIdType theCompID); + + virtual + void + Register() = 0; + + virtual + void + Destroy() = 0; + }; + typedef SALOME::GenericObjPtr PMinMaxController; + + + //---------------------------------------------------------------------------- + struct TVTKMinMaxController: virtual TMinMaxController, + virtual vtkObjectBase + { + virtual + void + Register() + { + vtkObjectBase::Register(NULL); + } + + virtual + void + Destroy() + { + vtkObjectBase::Delete(); + } + }; + + + //---------------------------------------------------------------------------- + class ColoredPrs3d_i; + + PMinMaxController + CreateDefaultMinMaxController(VISU::ColoredPrs3d_i* theColoredPrs3d); + + //============================================================================ class ColoredPrs3d_i : public virtual POA_VISU::ColoredPrs3d, + public virtual TMinMaxController, public virtual Prs3d_i { ColoredPrs3d_i(); @@ -53,6 +104,14 @@ namespace VISU virtual ~ColoredPrs3d_i(); + virtual + void + Register(); + + virtual + void + Destroy(); + virtual void RemoveFromStudy(); @@ -74,6 +133,34 @@ namespace VISU CORBA::Double GetMax(); + virtual + void + SetRange(CORBA::Double theMin, CORBA::Double theMax); + + virtual + vtkFloatingPointType + GetComponentMin(vtkIdType theCompID); + + virtual + vtkFloatingPointType + GetComponentMax(vtkIdType theCompID); + + virtual + void + SetSourceRange(); + + virtual + CORBA::Double + GetSourceMin(); + + virtual + CORBA::Double + GetSourceMax(); + + virtual + bool + IsRangeFixed(); + virtual void SetNbColors(CORBA::Long theNbColors); @@ -169,13 +256,21 @@ namespace VISU int theIteration, bool theIsFixedRange); - virtual const VISU::PField& + virtual + const VISU::PField& GetField() const; virtual CORBA::Boolean IsTimeStampFixed(); + + VISU::PMinMaxController + GetMinMaxController(); + + void + SetMinMaxController(const VISU::PMinMaxController& theController); + const std::string& GetMeshName() const; @@ -285,6 +380,8 @@ namespace VISU //---------------------------------------------------------------------------- protected: PField myField; + PMinMaxController myMinMaxController; + TEntity myEntity; std::string myFieldName; int myIteration; diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index eadbd8b0..bdef67b3 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -132,9 +132,6 @@ VISU::ScalarMap_i if(const ScalarMap_i* aPrs3d = dynamic_cast(theOrigin)){ ScalarMap_i* anOrigin = const_cast(aPrs3d); - SetRange(anOrigin->GetMin(), anOrigin->GetMax()); - myIsFixedRange = anOrigin->IsRangeFixed(); - SetScaling(anOrigin->GetScaling()); Update(); @@ -241,29 +238,7 @@ void VISU::ScalarMap_i ::SetRange(CORBA::Double theMin, CORBA::Double theMax) { - if(theMin > theMax) - return; - - struct TEvent: public SALOME_Event { - VISU_ScalarMapPL* myMap; - vtkFloatingPointType myRange[2]; - TEvent( VISU_ScalarMapPL* theMap, const vtkFloatingPointType& theMin , const vtkFloatingPointType& theMax) - :myMap(theMap) - { - myRange[0] = theMin; - myRange[1] = theMax; - } - - virtual - void - Execute() - { - myMap->SetScalarRange(myRange); - } - }; - - ProcessVoidEvent(new TEvent(myScalarMapPL, theMin, theMax)); - myIsFixedRange = true; + TSuperClass::SetRange(theMin, theMax); } @@ -312,62 +287,6 @@ VISU::ScalarMap_i myScalarMapPL->SetMapScale(theMapScale); } -//---------------------------------------------------------------------------- -bool -VISU::ScalarMap_i -::IsRangeFixed() -{ - return myIsFixedRange; -} - -//---------------------------------------------------------------------------- -void -VISU::ScalarMap_i -::SetSourceRange() -{ - if(IsTimeStampFixed()){ - ProcessVoidEvent(new TVoidMemFunEvent - (myScalarMapPL, &VISU_ScalarMapPL::SetSourceRange)); - }else{ - TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode()); - vtkFloatingPointType aScalarRange[2] = {aTMinMax.first, aTMinMax.second}; - ProcessVoidEvent(new TVoidMemFun1ArgEvent - (myScalarMapPL, &VISU_ScalarMapPL::SetScalarRange, aScalarRange)); - } - - myIsFixedRange = false; -} - -//---------------------------------------------------------------------------- -CORBA::Double -VISU::ScalarMap_i -::GetSourceMin() -{ - if(IsTimeStampFixed()){ - vtkFloatingPointType aRange[2]; - myScalarMapPL->GetSourceRange(aRange); - return aRange[0]; - }else{ - TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode()); - return aTMinMax.first; - } -} - -//---------------------------------------------------------------------------- -CORBA::Double -VISU::ScalarMap_i -::GetSourceMax() -{ - if(IsTimeStampFixed()){ - vtkFloatingPointType aRange[2]; - myScalarMapPL->GetSourceRange(aRange); - return aRange[1]; - }else{ - TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode()); - return aTMinMax.second; - } -} - //---------------------------------------------------------------------------- VISU_Actor* VISU::ScalarMap_i diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index 16d6490e..e9c8ec63 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -136,22 +136,6 @@ namespace VISU void SetMapScale(double theMapScale = 1.0); - virtual - bool - IsRangeFixed(); - - virtual - void - SetSourceRange(); - - virtual - CORBA::Double - GetSourceMin(); - - virtual - CORBA::Double - GetSourceMax(); - virtual void SameAs(const Prs3d_i* theOrigin); diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index dea9e8c5..fce481f9 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -75,10 +75,11 @@ #include "CASCatch.hxx" #endif -using namespace std; - -namespace VISU { - class ExecutionState { +namespace VISU +{ + //------------------------------------------------------------------------ + class ExecutionState + { bool myIsActive; QMutex myIsActiveMutex; public: @@ -101,6 +102,49 @@ namespace VISU { return state; } }; + + //------------------------------------------------------------------------ + struct TCompositeMinMaxController : virtual TVTKMinMaxController + { + typedef std::vector TMinMaxContainer; + TMinMaxContainer myMinMaxContainer; + + void + AddController(VISU::PMinMaxController theMinMaxController) + { + myMinMaxContainer.push_back(theMinMaxController); + } + + virtual + vtkFloatingPointType + GetComponentMin(vtkIdType theCompID) + { + vtkFloatingPointType aMin = TMinMaxController::GetComponentMin(theCompID); + if(!myMinMaxContainer.empty()){ + for(size_t anId = 0; anId < myMinMaxContainer.size(); anId++){ + VISU::PMinMaxController aMinMaxController = myMinMaxContainer[anId]; + aMin = std::min(aMin, aMinMaxController->GetComponentMin(theCompID)); + } + } + return aMin; + } + + virtual + vtkFloatingPointType + GetComponentMax(vtkIdType theCompID) + { + vtkFloatingPointType aMax = TMinMaxController::GetComponentMax(theCompID); + if(!myMinMaxContainer.empty()){ + for(size_t anId = 0; anId < myMinMaxContainer.size(); anId++){ + VISU::PMinMaxController aMinMaxController = myMinMaxContainer[anId]; + aMax = std::max(aMax, aMinMaxController->GetComponentMax(theCompID)); + } + } + return aMax; + } + }; + + typedef SALOME::GenericObjPtr PCompositeMinMaxController; } //------------------------------------------------------------------------ @@ -533,18 +577,37 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { else myFieldsAbsFrames.push_back(aData.myNbFrames); } - if ((theFieldNum == getNbFields() - 1) && aData.myPrsType != VISU::TGAUSSPOINTS){ - double aMin = getMinFieldsValue(myFieldsLst); - double aMax = getMaxFieldsValue(myFieldsLst); - for (int i = 0; i < getNbFields(); i++) - for(long aFrameId = 0; aFrameId < myFieldsLst[i].myNbFrames; aFrameId++) - if (aData.myPrsType == VISU::TISOSURFACE) { - if (VISU::IsoSurfaces_i* aPrs = dynamic_cast(myFieldsLst[i].myPrs[aFrameId])) - aPrs->SetSubRange(aMin, aMax); + + if (theFieldNum == getNbFields() - 1) { + if ( aData.myPrsType != VISU::TGAUSSPOINTS) { + + // Initialize the MinMax controller + VISU::PCompositeMinMaxController aMinMaxController(new VISU::TCompositeMinMaxController()); + if ( myAnimationMode == VISU::Animation::PARALLEL ) { + FieldData& aFieldData = getFieldData(theFieldNum); + VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[0]; + aMinMaxController->AddController(VISU::CreateDefaultMinMaxController(aPrs3d)); + } else { + for (int aFieldId = 0; aFieldId < getNbFields(); aFieldId++) { + FieldData& aFieldData = getFieldData(aFieldId); + VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[0]; + aMinMaxController->AddController(VISU::CreateDefaultMinMaxController(aPrs3d)); } - else - if (VISU::ScalarMap_i* aPrs = dynamic_cast(myFieldsLst[i].myPrs[aFrameId])) - aPrs->SetRange(aMin, aMax); + } + + double aMin = getMinFieldsValue(myFieldsLst); + double aMax = getMaxFieldsValue(myFieldsLst); + + for (int aFieldId = 0; aFieldId < getNbFields(); aFieldId++) { + FieldData& aFieldData = getFieldData(aFieldId); + for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) { + VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[aFrameId]; + aPrs3d->SetMinMaxController(aMinMaxController); + if (VISU::IsoSurfaces_i* anIsoSurfaces = dynamic_cast(aPrs3d)) + anIsoSurfaces->SetSubRange(aMin, aMax); + } + } + } } } }