]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug NPAL16764 - EDF 553 VISU :
authorapo <apo@opencascade.com>
Wed, 19 Sep 2007 12:41:10 +0000 (12:41 +0000)
committerapo <apo@opencascade.com>
Wed, 19 Sep 2007 12:41:10 +0000 (12:41 +0000)
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.

src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISU_I/Makefile.in
src/VISU_I/SALOME_GenericObjPointer.cc [new file with mode: 0644]
src/VISU_I/SALOME_GenericObjPointer.hh [new file with mode: 0644]
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_ScalarMap_i.cc
src/VISU_I/VISU_ScalarMap_i.hh
src/VISU_I/VISU_TimeAnimation.cxx

index dad851092150a4d623168f8c3c2aad4cf50dfd55..63352d3ad9fe0b8f278b0e94d7f39991fce5aada 100644 (file)
@@ -788,9 +788,9 @@ namespace
   template<class TPrs3d, class TDialog>
   void
   InitDiloglgFromPrsObject(TDialog* theDialog,
-                          FieldData& theData)
+                          TPrs3d* thePrs3d)
   {
-    theDialog->initFromPrsObject(dynamic_cast<TPrs3d*>(theData.myPrs[0]));
+    theDialog->initFromPrsObject(thePrs3d);
   }
 
 
@@ -798,9 +798,9 @@ namespace
   void
   InitDiloglgFromPrsObject
   <VISU::ScalarMapOnDeformedShape_i, VisuGUI_ScalarMapOnDeformedShapeDlg>(VisuGUI_ScalarMapOnDeformedShapeDlg* theDialog,
-                                                                         FieldData& theData)
+                                                                         VISU::ScalarMapOnDeformedShape_i* thePrs3d)
   {
-    theDialog->initFromPrsObject(dynamic_cast<VISU::ScalarMapOnDeformedShape_i*>(theData.myPrs[0]), true);
+    theDialog->initFromPrsObject(thePrs3d, true);
   }
 
 
@@ -811,25 +811,34 @@ namespace
          VISU_TimeAnimation* theAnimator)
   {
     TDialog* aDlg = new TDialog(theModule);
-    InitDiloglgFromPrsObject<TPrs3d, TDialog>(aDlg, theData);
+    TPrs3d* aPrs3d = dynamic_cast<TPrs3d*>(theData.myPrs[0]);
+    InitDiloglgFromPrsObject<TPrs3d, TDialog>(aDlg, aPrs3d);
     if (aDlg->exec()) {
-      aDlg->storeToPrsObject(dynamic_cast<TPrs3d*>(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<TPrs3d*>(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);
+         }
        }
       }
     }
index c59e054054570e349930e314846d0ab0a6059b47..df26fa84862703959425d6406bad9d114525df0b 100644 (file)
@@ -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 (file)
index 0000000..1e774e1
--- /dev/null
@@ -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 (file)
index 0000000..5492b59
--- /dev/null
@@ -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 <iosfwd>  // for std::basic_ostream
+
+namespace SALOME
+{
+  //----------------------------------------------------------------------------
+  template <class TGenericObj>
+  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<class TGenObj>
+    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<class TGenObj>
+    GenericObjPtr(const GenericObjPtr<TGenObj>& 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<class TGenObj>
+    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<class TGenObj>
+    GenericObjPtr& 
+    operator=(const GenericObjPtr<TGenObj>& 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<class T, class U> 
+inline 
+bool 
+operator<(SALOME::GenericObjPtr<T> const & a, SALOME::GenericObjPtr<U> const & b)
+{
+  return a.get() < b.get();
+}
+
+template<class T, class U> 
+inline
+bool 
+operator==(SALOME::GenericObjPtr<T> const & a, SALOME::GenericObjPtr<U> const & b)
+{
+  return a.get() == b.get();
+}
+
+template<class T, class U> 
+inline 
+bool 
+operator!=(SALOME::GenericObjPtr<T> const & a, SALOME::GenericObjPtr<U> const & b)
+{
+  return a.get() != b.get();
+}
+
+template<class Y> 
+std::ostream& 
+operator<< (std::ostream & os, SALOME::GenericObjPtr<Y> const & p)
+{
+  os << p.get();
+  return os;
+}
+
+
+#endif
index 02f5ce66e5f4793eddd790723eaa7fac9f97f0d6..b0da6dabaf115c9d90d35de0a481dd0d7287d8c1 100644 (file)
@@ -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<VISU_ScalarMapPL, vtkFloatingPointType*>
+                  (GetScalarMapPL(), &VISU_ScalarMapPL::SetScalarRange, aScalarRange));
+
+  myIsFixedRange = true;
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU::ColoredPrs3d_i
+::IsRangeFixed() 
+{ 
+  return myIsFixedRange; 
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3d_i
+::SetSourceRange()
+{
+  if(IsTimeStampFixed()){
+    ProcessVoidEvent(new TVoidMemFunEvent<VISU_ScalarMapPL>
+                    (myScalarMapPL, &VISU_ScalarMapPL::SetSourceRange));
+  }else{
+    vtkFloatingPointType aScalarRange[2] = {GetSourceMin(), GetSourceMax()};
+    ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ScalarMapPL, vtkFloatingPointType*>
+                    (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 
index 0fd4e6d182585a9287ecdbf291c006e77e6e7bcc..9bcc7ea8a1ae92251f4bd74b7d44fbaefc0d4614 100644 (file)
 #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<TMinMaxController> 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;
index eadbd8b0253bd07f6c56eaa5f5cc893018925aae..bdef67b3c5aa30e58b300df7f5cbc7e6fb91cd01 100644 (file)
@@ -132,9 +132,6 @@ VISU::ScalarMap_i
   if(const ScalarMap_i* aPrs3d = dynamic_cast<const ScalarMap_i*>(theOrigin)){
     ScalarMap_i* anOrigin = const_cast<ScalarMap_i*>(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<VISU_ScalarMapPL>
-                    (myScalarMapPL, &VISU_ScalarMapPL::SetSourceRange));
-  }else{
-    TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode());
-    vtkFloatingPointType aScalarRange[2] = {aTMinMax.first, aTMinMax.second};
-    ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_ScalarMapPL, vtkFloatingPointType*>
-                    (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
index 16d6490eb014eb046e85dc5674c7ecec38a61c40..e9c8ec63291a185eb9996d9fe221c1f48d8744f9 100644 (file)
@@ -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);
index dea9e8c5e20a9c308f6130e58e167db129a78c79..fce481f9071664ffb089c1d47d298fec29fddc29 100644 (file)
 #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<VISU::PMinMaxController> 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<TCompositeMinMaxController> 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<VISU::IsoSurfaces_i*>(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<VISU::ScalarMap_i*>(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<VISU::IsoSurfaces_i*>(aPrs3d))
+             anIsoSurfaces->SetSubRange(aMin, aMax);
+         }
+       }
+      }
     }
   }
 }