Salome HOME
Merge from PortingMED3 07Apr11
[modules/visu.git] / src / VISU_I / VISU_TimeAnimation.cxx
index 6d82f2673c4217b68ee895c4d684602446183029..497166a38e43062e3488d62a6ccc8d0dd027c31b 100644 (file)
@@ -1,32 +1,35 @@
-//  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 
-// 
+//  Copyright (C) 2007-2010  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.
+//
+//  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   : VISU_TimeAnimation.cxx
 //  Author : Vitaly SMETANNIKOV
 //  Module : VISU
-
+//
 #include "VISU_TimeAnimation.h"
 
 #ifdef WNT
 #include <windows.h>
 #include <vfw.h>
-#include <qmessagebox.h>
+#include <QMessageBox>
 #endif
 
 #include "VISUConfig.hh"
 #include "VISU_Mesh_i.hh"
 #include "VISU_IsoSurfaces_i.hh"
 #include "VISU_DeformedShape_i.hh"
-#include "VISU_ScalarMapOnDeformedShape_i.hh"
+#include "VISU_DeformedShapeAndScalarMap_i.hh"
 #include "VISU_CutPlanes_i.hh"
 #include "VISU_Plot3D_i.hh"
 #include "VISU_CutLines_i.hh"
+#include "VISU_CutSegment_i.hh"
 #include "VISU_Vectors_i.hh"
 #include "VISU_StreamLines_i.hh"
 #include "VISU_GaussPoints_i.hh"
 
 #include "SVTK_ViewWindow.h"
 
-#include "SALOME_Event.hxx"
+#include "SALOME_Event.h"
 
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_Application.h"
 #include "SUIT_Session.h"
 #include "SUIT_Study.h"
+#include "SUIT_MessageBox.h"
 
 #include "SALOMEDSClient_AttributeString.hxx"
 #include "SALOMEDSClient_AttributeName.hxx"
 
 #include "Utils_ExceptHandlers.hxx"
 
-#include <qpixmap.h>
-#include <qimage.h>
-#include <qstrlist.h>
-#include <qdir.h>
+#include <QPixmap>
+#include <QImage>
+#include <QImageWriter>
+#include <QStringList>
+#include <QDir>
 
 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 #define NO_CAS_CATCH
@@ -80,6 +86,7 @@
 #include <Standard_ErrorHandler.hxx>
 #endif
 
+using namespace std;
 
 //------------------------------------------------------------------------
 namespace VISU 
@@ -120,7 +127,7 @@ namespace VISU
 
     void
     AddController(ColoredPrs3d_i* theReference, 
-                 VISU::PMinMaxController theMinMaxController)
+                  VISU::PMinMaxController theMinMaxController)
     {
       myMinMaxContainer[ TKey( theReference ) ] = theMinMaxController;
     }
@@ -131,8 +138,8 @@ namespace VISU
     {
       TMinMaxContainer::iterator anIter = myMinMaxContainer.find( TKey( theFromPrs3 ) );
       if ( anIter != myMinMaxContainer.end() ) {
-       myMinMaxContainer.erase( anIter );
-       myMinMaxContainer[ TKey( theToPrs3d ) ] = VISU::CreateDefaultMinMaxController( theToPrs3d );      
+        myMinMaxContainer.erase( anIter );
+        myMinMaxContainer[ TKey( theToPrs3d ) ] = VISU::CreateDefaultMinMaxController( theToPrs3d );      
       }
     }
 
@@ -142,11 +149,11 @@ namespace VISU
     {
       vtkFloatingPointType aMin = TMinMaxController::GetComponentMin(theCompID);
       if ( !myMinMaxContainer.empty() ) {
-       TMinMaxContainer::const_iterator anIter = myMinMaxContainer.begin();
-       for(; anIter != myMinMaxContainer.end(); anIter++){
-         VISU::PMinMaxController aMinMaxController = anIter->second;
-         aMin = std::min(aMin, aMinMaxController->GetComponentMin(theCompID));
-       }
+        TMinMaxContainer::const_iterator anIter = myMinMaxContainer.begin();
+        for(; anIter != myMinMaxContainer.end(); anIter++){
+          VISU::PMinMaxController aMinMaxController = anIter->second;
+          aMin = std::min(aMin, aMinMaxController->GetComponentMin(theCompID));
+        }
       }
       return aMin;
     }
@@ -157,11 +164,11 @@ namespace VISU
     {
       vtkFloatingPointType aMax = TMinMaxController::GetComponentMax(theCompID);
       if ( !myMinMaxContainer.empty() ) {
-       TMinMaxContainer::const_iterator anIter = myMinMaxContainer.begin();
-       for(; anIter != myMinMaxContainer.end(); anIter++){
-         VISU::PMinMaxController aMinMaxController = anIter->second;
-         aMax = std::max(aMax, aMinMaxController->GetComponentMax(theCompID));
-       }
+        TMinMaxContainer::const_iterator anIter = myMinMaxContainer.begin();
+        for(; anIter != myMinMaxContainer.end(); anIter++){
+          VISU::PMinMaxController aMinMaxController = anIter->second;
+          aMax = std::max(aMax, aMinMaxController->GetComponentMax(theCompID));
+        }
       }
       return aMax;
     }
@@ -184,8 +191,7 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
   if (!CORBA::is_nil(theView3D)) {
     VISU::View3D_i* pView = dynamic_cast<VISU::View3D_i*>(GetServant(theView3D).in());
     SUIT_ViewWindow* aVW = pView->GetViewWindow();
-    myView = dynamic_cast<SVTK_ViewWindow*>(aVW);
-    connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) );
+    setViewer( dynamic_cast<SVTK_ViewWindow*>(aVW) );
   }
 
   myAnimationMode = VISU::Animation::PARALLEL;
@@ -201,27 +207,24 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
 
   myDumpPath = "";
   myAVIMaker = "jpeg2yuv";
+
+  myDumpMode = VISU::GetResourceMgr()->integerValue("VISU", "dump_mode", 0);
+  myTimeStampFrequency = VISU::GetResourceMgr()->integerValue("VISU", "time_stamp_frequency", 1);
 }
 
 
 //------------------------------------------------------------------------
 VISU_TimeAnimation::~VISU_TimeAnimation()
 {
-  if (!myView) {
-    MESSAGE("Viewer is not defined for animation");
-    return;
-  }
-
-  if (QThread::running() && !QThread::finished()) {
-    //myExecutionState->SetActive(false);
+  if (QThread::isRunning() && !QThread::isFinished()) {
     stopAnimation();
     QThread::wait(500);
-    if (QThread::running() && !QThread::finished()) {
+    if (QThread::isRunning() && !QThread::isFinished()) {
       QThread::terminate();
     }
   }
 
-  for (int i = 0; i < getNbFields(); i++) {
+  for (int i = 0; i < getNbFields() && myView; i++) {
     clearData(myFieldsLst[i]);
   }
   clearFieldData();
@@ -250,6 +253,12 @@ VISU_TimeAnimation::~VISU_TimeAnimation()
 }
 
 
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::_connectView()
+{
+  connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) );
+}
+
 //------------------------------------------------------------------------
 bool VISU_TimeAnimation::addField (_PTR(SObject) theField)
 {
@@ -260,6 +269,15 @@ bool VISU_TimeAnimation::addField (_PTR(SObject) theField)
   aNewData.myNbFrames = 0;
   aNewData.myPrsType = VISU::TSCALARMAP;
   aNewData.myOffset[0] = aNewData.myOffset[1] = aNewData.myOffset[2] = 0;
+
+  // initialize myResult in aNewData
+  _PTR(SObject) aSObj = theField->GetFather();
+  aSObj = aSObj->GetFather();
+  aSObj = aSObj->GetFather();
+  CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj);
+  if (CORBA::is_nil(anObject)) return false;
+  aNewData.myResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
+
   VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aNewData.myField);
   if(VISU::Storable::FindValue(aMap,"myComment") != "FIELD")
     return false;
@@ -283,7 +301,7 @@ bool VISU_TimeAnimation::addField (_PTR(SObject) theField)
       VISU::Storable::TRestoringMap aFMap = VISU::Storable::GetStorableMap(myFieldsLst.first().myField);
       long aNumComp = VISU::Storable::FindValue(aFMap, "myNumComponent").toLong();
       if ( aNumCompCurr != aNumComp )
-       return false;
+        return false;
     }
 
     if ( !myFieldsLst.isEmpty() )
@@ -331,7 +349,7 @@ void VISU_TimeAnimation::_clearData(FieldData& theData) {
   if (!theData.myActors.empty()) {
     for (int i = 0, iEnd = theData.myActors.size(); i < iEnd; i++) {
       if (theData.myActors[i] != 0) {
-       theData.myActors[i]->RemoveFromRender(aRen);
+        theData.myActors[i]->RemoveFromRender(aRen);
       }
     }
     theData.myActors.clear();
@@ -339,7 +357,7 @@ void VISU_TimeAnimation::_clearData(FieldData& theData) {
   if (!theData.myPrs.empty()) {
     for (int i = 0, iEnd = theData.myPrs.size(); i < iEnd; i++)
       if (theData.myPrs[i] != 0) {
-       theData.myPrs[i]->_remove_ref();
+        theData.myPrs[i]->_remove_ref();
       }
     theData.myPrs.clear();
   }
@@ -359,12 +377,12 @@ namespace
   template<class TPrs3d>
   void
   GeneratePresentations(_PTR(Study) theStudy,
-                       FieldData& theData,
-                       VISU::Result_i* theResult,
-                       bool theIsRangeDefined,
-                       CORBA::Double theTimeMin,
-                       CORBA::Double theTimeMax,
-                       QValueList<long> theSequence)
+                        FieldData& theData,
+                        VISU::Result_i* theResult,
+                        bool theIsRangeDefined,
+                        CORBA::Double theTimeMin,
+                        CORBA::Double theTimeMax,
+                        QList<long> theSequence)
   {
     _PTR(ChildIterator) anIter = theStudy->NewChildIterator(theData.myField);
     anIter->Next(); // First is reference on support
@@ -378,26 +396,26 @@ namespace
     long aSequenceIndex = 1;
     for(; anIter->More(); anIter->Next(), aSequenceIndex++){
       if (aFrameId == theData.myNbTimes) {
-       MESSAGE("There are extra timestamps in field");
-       return;
+        MESSAGE("There are extra timestamps in field");
+        return;
       }
       _PTR(SObject) aTimeStamp = anIter->Value();
       if(!aTimeStamp) 
-       continue;
+        continue;
 
       long aSequenceId = -1;
 
       theData.myTiming[aFrameId] = VISU_TimeAnimation::getTimeValue(aTimeStamp);
       if (theIsRangeDefined) {
-       if (theData.myTiming[aFrameId] < theTimeMin) 
-         continue;
-       if (theData.myTiming[aFrameId] > theTimeMax) 
-         break;
+        if (theData.myTiming[aFrameId] < theTimeMin) 
+          continue;
+        if (theData.myTiming[aFrameId] > theTimeMax) 
+          break;
       }
       else if (isSequenceDefined) {
-       aSequenceId = theSequence.findIndex( aSequenceIndex );
-       if( aSequenceId == -1 )
-         continue;
+        aSequenceId = theSequence.indexOf( aSequenceIndex );
+        if( aSequenceId == -1 )
+          continue;
       }
 
       VISU::Storable::TRestoringMap aTimeMap = VISU::Storable::GetStorableMap(aTimeStamp);
@@ -409,9 +427,9 @@ namespace
       bool anIsCreated = false;
       TPrs3d* aPresent = new TPrs3d(VISU::ColoredPrs3d_i::EDoNotPublish);
       aPresent->SetCResult(theResult);
-      aPresent->SetMeshName(aMeshName.latin1());
+      aPresent->SetMeshName(aMeshName.toLatin1().data());
       aPresent->SetEntity(anEntity);
-      aPresent->SetFieldName(aFieldName.latin1());
+      aPresent->SetFieldName(aFieldName.toLatin1().data());
       aPresent->SetTimeStampNumber(aTimeStampId);
       try{       
 #ifdef NO_CAS_CATCH
@@ -419,12 +437,12 @@ namespace
 #endif
         if(aPresent->Apply(false)){
           /*
-           if(isSequenceDefined)
-           {
-             theData.myPrs[aSequenceId] = aPresent;
-             aFrameId++;
-           }
-           else
+            if(isSequenceDefined)
+            {
+              theData.myPrs[aSequenceId] = aPresent;
+              aFrameId++;
+            }
+            else
           */
           theData.myPrs[aFrameId++] = aPresent;
           anIsCreated = true;
@@ -438,22 +456,22 @@ namespace
         INFOS("Unknown exception was occured!");
       }
       if(!anIsCreated)
-       aPresent->_remove_ref();
+        aPresent->_remove_ref();
     }
 
     theData.myNbFrames = aFrameId;
 
     if (theData.myPrsType != VISU::TGAUSSPOINTS) {
       for(long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++) {
-       if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(theData.myPrs[aFrameId])){
-         aPrs->SetOffset(theData.myOffset);
-       }
+        if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(theData.myPrs[aFrameId])){
+          aPrs->SetOffset(theData.myOffset);
+        }
       }
     }
   }
 }
 
-double getMinFieldsValue( QValueList<FieldData>& theFieldsLst )
+double getMinFieldsValue( QList<FieldData>& theFieldsLst )
 {
   // for successive animation mode only
   double aRes;
@@ -471,7 +489,7 @@ double getMinFieldsValue( QValueList<FieldData>& theFieldsLst )
   return aRes;
 }
 
-double getMaxFieldsValue( QValueList<FieldData>& theFieldsLst )
+double getMaxFieldsValue( QList<FieldData>& theFieldsLst )
 {
   // for successive animation mode only
   double aRes;
@@ -489,7 +507,12 @@ double getMaxFieldsValue( QValueList<FieldData>& theFieldsLst )
   return aRes;
 }
 
-void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) {
+void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum)
+{
+  int nbf = myFieldsLst.size();
+  if( theFieldNum<0 || theFieldNum>nbf-1 )
+    return;
+
   FieldData& aData = myFieldsLst[theFieldNum];
 
   // Delete previous presentations
@@ -503,7 +526,7 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) {
   aData.myPrs.resize(aData.myNbTimes,NULL);
   aData.myTiming.resize(aData.myNbTimes);
 
-  QValueList<long> aSequence;
+  QList<long> aSequence;
   if( isSequenceDefined() )
   {
     bool ok = getIndicesFromSequence( mySequence, aSequence );
@@ -515,93 +538,103 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) {
   switch (aData.myPrsType) {
   case VISU::TSCALARMAP:
     GeneratePresentations<ScalarMap_i>(myStudy,
-                                      aData,
-                                      aResult,
-                                      isRangeDefined(),
-                                      myTimeMinVal,
-                                      myTimeMaxVal,
-                                      aSequence);
+                                       aData,
+                                       aResult,
+                                       isRangeDefined(),
+                                       myTimeMinVal,
+                                       myTimeMaxVal,
+                                       aSequence);
     break;
   case VISU::TISOSURFACES: // Iso Surfaces
     GeneratePresentations<IsoSurfaces_i>(myStudy,
-                                        aData,
-                                        aResult,
-                                        isRangeDefined(),
-                                        myTimeMinVal,
-                                        myTimeMaxVal,
-                                        aSequence);
+                                         aData,
+                                         aResult,
+                                         isRangeDefined(),
+                                         myTimeMinVal,
+                                         myTimeMaxVal,
+                                         aSequence);
     break;
   case VISU::TCUTPLANES: // Cut Planes
     GeneratePresentations<CutPlanes_i>(myStudy,
-                                      aData,
-                                      aResult,
-                                      isRangeDefined(),
-                                      myTimeMinVal,
-                                      myTimeMaxVal,
-                                      aSequence);
+                                       aData,
+                                       aResult,
+                                       isRangeDefined(),
+                                       myTimeMinVal,
+                                       myTimeMaxVal,
+                                       aSequence);
     break;
   case VISU::TCUTLINES: // Cut Lines
     GeneratePresentations<CutLines_i>(myStudy,
-                                     aData,
-                                     aResult,
-                                     isRangeDefined(),
-                                     myTimeMinVal,
-                                     myTimeMaxVal,
-                                     aSequence);
+                                      aData,
+                                      aResult,
+                                      isRangeDefined(),
+                                      myTimeMinVal,
+                                      myTimeMaxVal,
+                                      aSequence);
+    break;
+  case VISU::TCUTSEGMENT: // Cut Segment
+    GeneratePresentations<CutSegment_i>(myStudy,
+                                        aData,
+                                        aResult,
+                                        isRangeDefined(),
+                                        myTimeMinVal,
+                                        myTimeMaxVal,
+                                        aSequence);
     break;
   case VISU::TPLOT3D: // Plot3d
     GeneratePresentations<Plot3D_i>(myStudy,
-                                   aData,
-                                   aResult,
-                                   isRangeDefined(),
-                                   myTimeMinVal,
-                                   myTimeMaxVal,
-                                   aSequence);
+                                    aData,
+                                    aResult,
+                                    isRangeDefined(),
+                                    myTimeMinVal,
+                                    myTimeMaxVal,
+                                    aSequence);
     break;
   case VISU::TDEFORMEDSHAPE: // Deformed Shape
     GeneratePresentations<DeformedShape_i>(myStudy,
-                                          aData,
-                                          aResult,
-                                          isRangeDefined(),
-                                          myTimeMinVal,
-                                          myTimeMaxVal,
-                                          aSequence);
+                                           aData,
+                                           aResult,
+                                           isRangeDefined(),
+                                           myTimeMinVal,
+                                           myTimeMaxVal,
+                                           aSequence);
     break;
   case VISU::TVECTORS: // Vectors
     GeneratePresentations<Vectors_i>(myStudy,
-                                    aData,
-                                    aResult,
-                                    isRangeDefined(),
-                                    myTimeMinVal,
-                                    myTimeMaxVal,
-                                    aSequence);
+                                     aData,
+                                     aResult,
+                                     isRangeDefined(),
+                                     myTimeMinVal,
+                                     myTimeMaxVal,
+                                     aSequence);
     break;
   case VISU::TSTREAMLINES: // Stream Lines
     GeneratePresentations<StreamLines_i>(myStudy,
-                                        aData,
-                                        aResult,
-                                        isRangeDefined(),
-                                        myTimeMinVal,
-                                        myTimeMaxVal,
-                                        aSequence);
+                                         aData,
+                                         aResult,
+                                         isRangeDefined(),
+                                         myTimeMinVal,
+                                         myTimeMaxVal,
+                                         aSequence);
     break;
   case VISU::TGAUSSPOINTS: // Gauss Points
     GeneratePresentations<GaussPoints_i>(myStudy,
-                                        aData,
-                                        aResult,
-                                        isRangeDefined(),
-                                        myTimeMinVal,
-                                        myTimeMaxVal,
-                                        aSequence);
+                                         aData,
+                                         aResult,
+                                         isRangeDefined(),
+                                         myTimeMinVal,
+                                         myTimeMaxVal,
+                                         aSequence);
     break;
   case VISU::TSCALARMAPONDEFORMEDSHAPE: // Scalar map on deformed shape
-    GeneratePresentations<ScalarMapOnDeformedShape_i>(myStudy,
-                                                     aData,
-                                                     aResult,
-                                                     isRangeDefined(),
-                                                     myTimeMinVal,
-                                                     myTimeMaxVal,
-                                                     aSequence);
+  case VISU::TDEFORMEDSHAPEANDSCALARMAP:
+    GeneratePresentations<DeformedShapeAndScalarMap_i>(myStudy,
+                                                       aData,
+                                                       aResult,
+                                                       isRangeDefined(),
+                                                       myTimeMinVal,
+                                                       myTimeMaxVal,
+                                                       aSequence);
     break;
   default:
     MESSAGE("Not implemented for this presentation type: " << aData.myPrsType);
@@ -617,34 +650,34 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) {
       myFieldsAbsFrames.push_back(aData.myNbFrames);
 
     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( aPrs3d, VISU::CreateDefaultMinMaxController( aPrs3d ) );
-       } else {
-         for (int aFieldId = 0; aFieldId < getNbFields(); aFieldId++) {
-           FieldData& aFieldData = getFieldData(aFieldId);
-           VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[0];
-           aMinMaxController->AddController( aPrs3d, VISU::CreateDefaultMinMaxController( aPrs3d ) );
-         }
-       }
-
-       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);
-         }
-       }
+      if ( aData.myPrsType != VISU::TGAUSSPOINTS && aData.myPrsType != TDEFORMEDSHAPEANDSCALARMAP && aData.myPrsType != TSCALARMAPONDEFORMEDSHAPE) {
+
+        // 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( aPrs3d, VISU::CreateDefaultMinMaxController( aPrs3d ) );
+        } else {
+          for (int aFieldId = 0; aFieldId < getNbFields(); aFieldId++) {
+            FieldData& aFieldData = getFieldData(aFieldId);
+            VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[0];
+            aMinMaxController->AddController( aPrs3d, VISU::CreateDefaultMinMaxController( aPrs3d ) );
+          }
+        }
+
+        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);
+          }
+        }
       }
     }
   }
@@ -669,17 +702,17 @@ CORBA::Boolean VISU_TimeAnimation::_generateFrames() {
     for (long j = 0; j < aData.myNbFrames; j++) {
       VISU_Actor* aActor = NULL;
       try{
-       aData.myPrs[j]->SetOffset(aData.myOffset);
-       aActor = aData.myPrs[j]->CreateActor();
-       myView->AddActor(aActor);
-       bool condition = ( myAnimationMode == VISU::Animation::PARALLEL ) ? (j == 0) : (j == 0 && i == 0);
-       if(condition)
-         aActor->VisibilityOn();
-       else
-         aActor->VisibilityOff();
+        aData.myPrs[j]->SetOffset(aData.myOffset);
+        aActor = aData.myPrs[j]->CreateActor();
+        myView->AddActor(aActor);
+        bool condition = ( myAnimationMode == VISU::Animation::PARALLEL ) ? (j == 0) : (j == 0 && i == 0);
+        if(condition)
+          aActor->VisibilityOn();
+        else
+          aActor->VisibilityOff();
       }catch(...){ //catch(std::runtime_error& exc){
-       aNoError = false;
-       myLastError += QString("%1 ").arg(aData.myTiming[j]);
+        aNoError = false;
+        myLastError += QString("%1 ").arg(aData.myTiming[j]);
       }
       aData.myActors[j] = aActor;
     }
@@ -687,7 +720,7 @@ CORBA::Boolean VISU_TimeAnimation::_generateFrames() {
   myFrame = 0;
   myLastError += QString(" timestamp(s) cannot be created.");
   ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                           myFrame, myFieldsLst[0].myTiming[myFrame]));
+                                                                            myFrame, myFieldsLst[0].myTiming[myFrame]));
   myView->Repaint();
   return aNoError;
 }
@@ -710,9 +743,9 @@ void VISU_TimeAnimation::_clearView() {
     FieldData& aData = myFieldsLst[i];
     if (!aData.myActors.empty()) {
       for (int i = 0, iEnd = aData.myActors.size(); i < iEnd; i++) {
-       if (aData.myActors[i] != 0) {
-         aData.myActors[i]->RemoveFromRender(aRen);
-       }
+        if (aData.myActors[i] != 0) {
+          aData.myActors[i]->RemoveFromRender(aRen);
+        }
       }
       aData.myActors.clear();
     }
@@ -729,6 +762,10 @@ void VISU_TimeAnimation::clearView()
 
 //------------------------------------------------------------------------
 void VISU_TimeAnimation::_visibilityOff(int num_field, int num_frame) {
+  if (!myView) {
+    MESSAGE("Viewer is not defined for animation");
+    return;
+  }
   if ( num_field < 0 || num_frame < 0 ) return;
   FieldData& aData = myFieldsLst[num_field];
   if ( aData.myActors.empty() ) return;
@@ -784,12 +821,6 @@ void VISU_TimeAnimation::startAnimation()
                    (this,&VISU_TimeAnimation::_startAnimation));
 }
 
-//------------------------------------------------------------------------
-CORBA::Boolean VISU_TimeAnimation::isRunning()
-{
-  return myExecutionState->IsActive();
-}
-
 //------------------------------------------------------------------------
 void VISU_TimeAnimation::_nextFrame() {
   if (!myView) {
@@ -805,36 +836,36 @@ void VISU_TimeAnimation::_nextFrame() {
 
     if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
       for (i = 0; i < getNbFields(); i++)
-       if (myFieldsLst[i].myActors[myFrame] != 0)
-         visibilityOff(i, myFrame);
+        if (myFieldsLst[i].myActors[myFrame] != 0)
+          visibilityOff(i, myFrame);
     }
     else { //successive animation mode
       aPair = getRelativeFrameNumber(myFrame);
       aFieldId = aPair.first;
       aFrameId = aPair.second;
       if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
-       visibilityOff(aFieldId, aFrameId);
+        visibilityOff(aFieldId, aFrameId);
     }
 
     myFrame++;
 
     if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
       for (i = 0; i < getNbFields(); i++)
-       if (myFieldsLst[i].myActors[myFrame] != 0)
-         myFieldsLst[i].myActors[myFrame]->VisibilityOn();
+        if (myFieldsLst[i].myActors[myFrame] != 0)
+          myFieldsLst[i].myActors[myFrame]->VisibilityOn();
 
       ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                               myFrame, myFieldsLst[0].myTiming[myFrame]));
+                                                                                myFrame, myFieldsLst[0].myTiming[myFrame]));
     }
     else { //successive animation mode
       aPair = getRelativeFrameNumber(myFrame);
       aFieldId = aPair.first;
       aFrameId = aPair.second;
       if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
-       myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
+        myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
 
       ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                               myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
+                                                                                myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
     }
     myView->Repaint();
   }
@@ -862,36 +893,36 @@ void VISU_TimeAnimation::_prevFrame() {
 
     if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
       for (i = 0; i < getNbFields(); i++)
-       if (myFieldsLst[i].myActors[myFrame] != 0)
-         visibilityOff(i, myFrame);
+        if (myFieldsLst[i].myActors[myFrame] != 0)
+          visibilityOff(i, myFrame);
     }
     else { //successive animation mode
       aPair = getRelativeFrameNumber(myFrame);
       aFieldId = aPair.first;
       aFrameId = aPair.second;
       if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
-         visibilityOff(aFieldId, aFrameId);
+          visibilityOff(aFieldId, aFrameId);
     }
 
     myFrame--;
 
     if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
       for (i = 0; i < getNbFields(); i++)
-       if (myFieldsLst[i].myActors[myFrame] != 0)
-         myFieldsLst[i].myActors[myFrame]->VisibilityOn();
+        if (myFieldsLst[i].myActors[myFrame] != 0)
+          myFieldsLst[i].myActors[myFrame]->VisibilityOn();
 
       ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                               myFrame, myFieldsLst[0].myTiming[myFrame]));
+                                                                                myFrame, myFieldsLst[0].myTiming[myFrame]));
     }
     else { //successive animation mode
       aPair = getRelativeFrameNumber(myFrame);
       aFieldId = aPair.first;
       aFrameId = aPair.second;
       if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
-         myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
+          myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
 
       ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                               myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
+                                                                                myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
     }
     myView->Repaint();
   }
@@ -915,8 +946,8 @@ void VISU_TimeAnimation::_firstFrame() {
   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
     for (i = 0; i < getNbFields(); i++)
       if(!myFieldsLst[i].myActors.empty())
-       if (myFieldsLst[i].myActors[myFrame] != 0)
-         visibilityOff(i, myFrame);
+        if (myFieldsLst[i].myActors[myFrame] != 0)
+          visibilityOff(i, myFrame);
     }
   else { //successive animation mode
     std::pair<int,long> aPair = getRelativeFrameNumber(myFrame);
@@ -924,7 +955,7 @@ void VISU_TimeAnimation::_firstFrame() {
     long aFrameId = aPair.second;
     if(!myFieldsLst[aFieldId].myActors.empty())
       if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
-       visibilityOff(aFieldId, aFrameId);
+        visibilityOff(aFieldId, aFrameId);
   }
   myFrame = 0;
 
@@ -937,11 +968,11 @@ void VISU_TimeAnimation::_firstFrame() {
   for (i = 0; i < imax; i++)
     if(!myFieldsLst[i].myActors.empty())
       if (myFieldsLst[i].myActors[myFrame] != 0)
-       myFieldsLst[i].myActors[myFrame]->VisibilityOn();
+        myFieldsLst[i].myActors[myFrame]->VisibilityOn();
 
   if(!myFieldsLst[0].myTiming.empty()){
     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
+                                                                              myFrame, myFieldsLst[0].myTiming[myFrame]));
     myView->Repaint();
   }
 }
@@ -968,7 +999,7 @@ void VISU_TimeAnimation::_lastFrame() {
   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
     for (i = 0; i < getNbFields(); i++)
       if (myFieldsLst[i].myActors[myFrame] != 0)
-       visibilityOff(i, myFrame);
+        visibilityOff(i, myFrame);
   }
   else { //successive animation mode
     aPair = getRelativeFrameNumber(myFrame);
@@ -983,20 +1014,20 @@ void VISU_TimeAnimation::_lastFrame() {
   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
     for (i = 0; i < getNbFields(); i++)
       if (myFieldsLst[i].myActors[myFrame] != 0)
-       myFieldsLst[i].myActors[myFrame]->VisibilityOn();
+        myFieldsLst[i].myActors[myFrame]->VisibilityOn();
     
     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
+                                                                              myFrame, myFieldsLst[0].myTiming[myFrame]));
   }
   else { //successive animation mode
     aPair = getRelativeFrameNumber(myFrame);
     aFieldId = aPair.first;
     aFrameId = aPair.second;
     if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
-       myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
+        myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
 
     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                             myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
+                                                                              myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
   }
 
   myView->Repaint();
@@ -1028,14 +1059,14 @@ void VISU_TimeAnimation::_gotoFrame(CORBA::Long theFrame) {
   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
     for (i = 0; i < getNbFields(); i++)
       if (myFieldsLst[i].myActors[myFrame] != 0)
-       visibilityOff(i, myFrame);
+        visibilityOff(i, myFrame);
   }
   else { //successive animation mode
     aPair = getRelativeFrameNumber(myFrame);
     aFieldId = aPair.first;
     aFrameId = aPair.second;
     if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
-       visibilityOff(aFieldId, aFrameId);
+        visibilityOff(aFieldId, aFrameId);
   }
 
   myFrame = theFrame;
@@ -1043,20 +1074,20 @@ void VISU_TimeAnimation::_gotoFrame(CORBA::Long theFrame) {
   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
     for (i = 0; i < getNbFields(); i++)
       if (myFieldsLst[i].myActors[myFrame] != 0)
-       myFieldsLst[i].myActors[myFrame]->VisibilityOn();
+        myFieldsLst[i].myActors[myFrame]->VisibilityOn();
 
     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
+                                                                              myFrame, myFieldsLst[0].myTiming[myFrame]));
   }
   else { //successive animation mode
     aPair = getRelativeFrameNumber(myFrame);
     aFieldId = aPair.first;
     aFrameId = aPair.second;
     if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
-       myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
+        myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
 
     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                             myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
+                                                                              myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
   }
 
   myView->Repaint();
@@ -1090,6 +1121,21 @@ VISU::ColoredPrs3d_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField,
   return myFieldsLst[theField].myPrs[theFrame]->_this();
 }
 
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType) {
+  if ( theFieldNum < 0 || theFieldNum >= myFieldsLst.size() )
+    return;
+
+  myFieldsLst[theFieldNum].myPrsType = theType;
+}
+
+//------------------------------------------------------------------------
+VISU::VISUType VISU_TimeAnimation::getPresentationType(CORBA::Long theFieldNum) {
+  if ( theFieldNum < 0 || theFieldNum >= myFieldsLst.size() )
+    return VISU::TNONE;
+  
+  return myFieldsLst[theFieldNum].myPrsType;
+}
 
 //------------------------------------------------------------------------
 CORBA::Long VISU_TimeAnimation::getNbFrames() {
@@ -1112,9 +1158,9 @@ long VISU_TimeAnimation::getAbsoluteFrameNumber(std::pair<int,long> theFieldTime
     }
     else { //successive animation mode
       if ( aFieldId == 0 && aFrameNum <= myFieldsAbsFrames[aFieldId] )
-       aRes = aFrameNum;
+        aRes = aFrameNum;
       else if ( aFieldId && aFrameNum <= myFieldsAbsFrames[aFieldId] - myFieldsAbsFrames[aFieldId-1] )
-       aRes = myFieldsAbsFrames[aFieldId-1] + aFrameNum;
+        aRes = myFieldsAbsFrames[aFieldId-1] + aFrameNum;
     }
   }
   return aRes - 1;
@@ -1132,21 +1178,21 @@ std::pair<int,long> VISU_TimeAnimation::getRelativeFrameNumber(long theFrame)
     }
     else { //successive animation mode
       for (int i = 0, iEnd = myFieldsAbsFrames.size(); i < iEnd; i++)
-       if ( myFieldsAbsFrames[i] >= theFrame ) {
-         aRes.first = i;
-         if ( i == 0 )
-           aRes.second = theFrame - 1;
-         else
-           aRes.second = theFrame-myFieldsAbsFrames[i-1] - 1;
-         break;
-       }
+        if ( myFieldsAbsFrames[i] >= theFrame ) {
+          aRes.first = i;
+          if ( i == 0 )
+            aRes.second = theFrame - 1;
+          else
+            aRes.second = theFrame-myFieldsAbsFrames[i-1] - 1;
+          break;
+        }
     }
   }
   return aRes;
 }
 
 //------------------------------------------------------------------------
-void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList<int>& theIndexList )
+void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QList<int>& theIndexList )
 {
   double k = 1;
   double aOneVal = 1;
@@ -1163,20 +1209,22 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList<int>&
     if (myExecutionState->IsActive()) {
       for (int i = 0; i < getNbFields(); i++) {
         FieldData& aData = myFieldsLst[i];
-       if (aData.myNbFrames == 0)
-         continue;
+        if (aData.myNbFrames == 0)
+          continue;
         if (myFrame > 0) {
           if (aData.myActors[myFrame-1] != 0)
             visibilityOff(i, myFrame-1);
         } else {
-         if (aData.myActors[aData.myNbFrames-1] != 0)
-           visibilityOff(i, aData.myNbFrames-1);
+          if (aData.myActors[aData.myNbFrames-1] != 0)
+            visibilityOff(i, aData.myNbFrames-1);
         }
-        if (aData.myActors[myFrame] != 0) {
+        if (aData.myActors[myFrame] != 0 && myView) {
           ProcessVoidEvent(new TVoidMemFunEvent<VISU_Actor>(aData.myActors[myFrame],
                                                             &VISU_Actor::VisibilityOn));
         }
       }
+      if (!myView)
+        return;
       bool repainArg = false;
       ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
                                                                       &SVTK_ViewWindow::Repaint,
@@ -1213,10 +1261,10 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList<int>&
       // We must unlock mutex for some time before grabbing to allow view updating
       msleep(delay);
       if (!myExecutionState->IsActive()) 
-       return;
+        return;
 
       if (!(aFirstFieldData.myField)) // break, if field was deleted.
-       break;
+        break;
 
       saveImages( 0, aOneVal, aNbFiles, theIndexList );
     }
@@ -1228,16 +1276,16 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList<int>&
     if (myFrame == aFirstFieldData.myNbFrames) {
       if (!myCycling) {
         aHasNextFrame = false;
-       myFrame--;
+        myFrame--;
       }
       else
-       myFrame = 0;
+        myFrame = 0;
     }
   } // while (aHasNextFrame && myExecutionState->IsActive())
 }
 
 //------------------------------------------------------------------------
-void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QValueList<int>& theIndexList )
+void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QList<int>& theIndexList )
 {
   if (myFrame >= getNbFrames() - 1)
   {
@@ -1266,11 +1314,11 @@ void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QValueList<int
       if ( !aData.myPrs[0] ) continue;
       for (; aFrame < aData.myNbFrames && myExecutionState->IsActive(); aFrame++, myFrame++)
       {
-       ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>
+        ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>
                          (this, &VISU_TimeAnimation::_emitFrameChanged,
                           myFrame, myFieldsLst[aFieldId].myTiming[aFrame]));
 
-       if (myExecutionState->IsActive()) {
+        if (myExecutionState->IsActive()) {
           if (aFrame > 0) {
             if (aData.myActors[aFrame-1] != 0)
               visibilityOff(aFieldId, aFrame-1);
@@ -1284,53 +1332,55 @@ void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QValueList<int
             if (aData.myActors[aData.myNbFrames-1] != 0)
               visibilityOff(aFieldId, aData.myNbFrames-1);
           }
-          if (aData.myActors[aFrame] != 0) {
+          if (aData.myActors[aFrame] != 0 && myView) {
             ProcessVoidEvent(new TVoidMemFunEvent<VISU_Actor>(aData.myActors[aFrame],
                                                               &VISU_Actor::VisibilityOn));
           }
 
+          if (!myView)
+            return;
           bool repainArg = false;
           ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
                                                                           &SVTK_ViewWindow::Repaint,
                                                                           repainArg));
-       }
-
-       k = 1;
-       if (myProportional) {
-         switch (aFrame) {
-         case 0:
-           break;
-         case 1:
-           if (aFirstFieldData.myNbFrames > 2)
-             k = (aFirstFieldData.myTiming[aFrame+1] -
-                  aFirstFieldData.myTiming[aFrame]) / aOneVal;
-           break;
-         default:
-           if (aFrame < (aFirstFieldData.myNbFrames - 1))
-             k = (aFirstFieldData.myTiming[aFrame+1] -
-                  aFirstFieldData.myTiming[aFrame]) / aOneVal;
-         }
-       }
-       int delay = (int)(1000. * k / mySpeed);
-       theIsDumping = !myDumpPath.isEmpty();
-       if (delay < 1 && theIsDumping) {
-         // We must unlock mutex for some time before grabbing to allow view updating
-         delay = 1;
-       }
-       msleep(delay);
-
-       if (!myExecutionState->IsActive()) return;
-
-       if (theIsDumping) {
-         // We must unlock mutex for some time before grabbing to allow view updating
-         msleep(delay);
-         if (!myExecutionState->IsActive()) return;
-
-         if (!(myFieldsLst[aFieldId].myField)) // break, if field was deleted.
-           break;
-
-         saveImages( aFieldId, aOneVal, aNbFiles, theIndexList );
-       }
+        }
+
+        k = 1;
+        if (myProportional) {
+          switch (aFrame) {
+          case 0:
+            break;
+          case 1:
+            if (aFirstFieldData.myNbFrames > 2)
+              k = (aFirstFieldData.myTiming[aFrame+1] -
+                   aFirstFieldData.myTiming[aFrame]) / aOneVal;
+            break;
+          default:
+            if (aFrame < (aFirstFieldData.myNbFrames - 1))
+              k = (aFirstFieldData.myTiming[aFrame+1] -
+                   aFirstFieldData.myTiming[aFrame]) / aOneVal;
+          }
+        }
+        int delay = (int)(1000. * k / mySpeed);
+        theIsDumping = !myDumpPath.isEmpty();
+        if (delay < 1 && theIsDumping) {
+          // We must unlock mutex for some time before grabbing to allow view updating
+          delay = 1;
+        }
+        msleep(delay);
+
+        if (!myExecutionState->IsActive()) return;
+
+        if (theIsDumping) {
+          // We must unlock mutex for some time before grabbing to allow view updating
+          msleep(delay);
+          if (!myExecutionState->IsActive()) return;
+
+          if (!(myFieldsLst[aFieldId].myField)) // break, if field was deleted.
+            break;
+
+          saveImages( aFieldId, aOneVal, aNbFiles, theIndexList );
+        }
       } // for (; aFrame < aData.myNbFrames && myExecutionState->IsActive(); aFrame++, myFrame++)
     } // for (int aFieldId = 0;
 
@@ -1347,33 +1397,42 @@ void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QValueList<int
 
 //------------------------------------------------------------------------
 void VISU_TimeAnimation::saveImages( int theFieldId, 
-                                    double& theOneVal, int& theNbFiles, 
-                                    QValueList<int>& theIndexList )
+                                     double& theOneVal, int& theNbFiles, 
+                                     QList<int>& theIndexList )
 {
   if (myDumpFormat.compare("AVI") != 0) {
     QString aFile(myDumpPath);
 
+    int aFrameNb = myFrame; // parallel animation mode
+    if ( myAnimationMode == VISU::Animation::SUCCESSIVE ) // successive animation mode
+      aFrameNb = getRelativeFrameNumber(myFrame).second;
+
+    int aMaxNb = myFieldsLst[theFieldId].myTiming.size();
+    int nbDigits = QString("%1").arg(aMaxNb).length();
+    QString aFormat = QString("%.%1d_").arg(nbDigits);
+
     QString aName;
-    if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode
-      aName = QString("%1").arg(myFieldsLst[theFieldId].myTiming[myFrame]);
-    else // successive animation mode
-      aName = QString("%1").arg(myFieldsLst[theFieldId].myTiming[getRelativeFrameNumber(myFrame).second]);
+    aName.sprintf(aFormat.toLatin1().data(), aFrameNb);
+    aName += QString("%1").arg(myFieldsLst[theFieldId].myTiming[aFrameNb]);
 
     int aPos = -1;
-    while ((aPos = aName.find(".")) > -1 )
+    while ((aPos = aName.indexOf(".")) > -1 )
       aName.replace(aPos, 1, "_");
     aFile += aName;
     aFile += ".";
-    aFile += myDumpFormat.lower();
+    aFile += myDumpFormat.toLower();
     ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
-                    (myView,&SVTK_ViewWindow::RefreshDumpImage)); // IPAL13602
+                     (myView,&SVTK_ViewWindow::RefreshDumpImage)); // IPAL13602
     ProcessEvent(new TMemFun2ArgEvent<SUIT_ViewWindow,bool,const QString&,const QString&>
-                (myView,&SUIT_ViewWindow::dumpViewToFormat,aFile,myDumpFormat));
+                 (myView,&SUIT_ViewWindow::dumpViewToFormat,aFile,myDumpFormat));
   } else {
     QFileInfo aFileInfo(myDumpPath);
-    QString aDirPath = aFileInfo.dirPath(true);
+    QString aDirPath = aFileInfo.absolutePath();
     QString aBaseName = aFileInfo.fileName();
     
+    if( myTimeStampFrequency > 1 && myFrame % myTimeStampFrequency != 0 )
+      return;
+
     switch (myFrame) {
     case 0: 
       break;
@@ -1382,18 +1441,18 @@ void VISU_TimeAnimation::saveImages( int theFieldId,
       break;
     default:
       if (myProportional) {
-       FieldData& aFirstFieldData = myFieldsLst[0];
-       double p = (aFirstFieldData.myTiming[myFrame] -
-                   aFirstFieldData.myTiming[myFrame-1]) / theOneVal;
-       myFileIndex += (long) (5*p);
+        FieldData& aFirstFieldData = myFieldsLst[0];
+        double p = (aFirstFieldData.myTiming[myFrame] -
+                    aFirstFieldData.myTiming[myFrame-1]) / theOneVal;
+        myFileIndex += (long) (5*p);
       } else {
-       myFileIndex += 5;
+        myFileIndex += 5;
       }
     }
     
     QString aFile = aDirPath + QDir::separator() + aBaseName;
     aFile += "_";
-    aFile += QString("%1").arg(myFileIndex).rightJustify(8, '0');
+    aFile += QString("%1").arg(myFileIndex).rightJustified(8, '0');
     aFile += ".jpeg";
     
     /* check image size is divisable 16
@@ -1407,8 +1466,8 @@ void VISU_TimeAnimation::saveImages( int theFieldId,
       int height = img.height(); height = (height/16)*16;
       QImage copy = img.copy(0, 0, width, height);
       if (copy.save(aFile, "JPEG")) {
-       theIndexList.append(myFileIndex);
-       theNbFiles++;
+        theIndexList.append(myFileIndex);
+        theNbFiles++;
       }
     }
   }
@@ -1424,7 +1483,7 @@ void VISU_TimeAnimation::run()
 
   bool isDumping = !myDumpPath.isEmpty();
   myFileIndex = 0;
-  QValueList<int> anIndexList;
+  QList<int> anIndexList;
 
   if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode
     parallelAnimation( isDumping, anIndexList );
@@ -1433,32 +1492,39 @@ void VISU_TimeAnimation::run()
 
   // make AVI file if need
   if (isDumping && myDumpFormat.compare("AVI") == 0 && myExecutionState->IsActive()) {
-    double aFPS = 17.3 * mySpeed;
+    double aFPS = 17.3 * mySpeed / myTimeStampFrequency;
 
     QFileInfo aFileInfo(myDumpPath);
-    QString aDirPath = aFileInfo.dirPath(true);
+    QString aDirPath = aFileInfo.absolutePath();
     QString aBaseName = aFileInfo.fileName();
 
     // add missing files
     if (anIndexList.count() > 1) {
-      QString aFFile = aDirPath + QDir::separator() + aBaseName;
+      QString aFFile = aDirPath + "/" + aBaseName;
       aFFile += QString("_%1.jpeg");
       int aStartIndex = anIndexList[0], anEndIndex;
       for (int i = 1; i < anIndexList.count(); i++) {
-       anEndIndex = anIndexList[i];
-       QString aCurFile = aFFile.arg(QString::number(aStartIndex).rightJustify(8, '0'));
-       QStringList aCommands;
-       for (int j = aStartIndex+1; j < anEndIndex; j++) {
-         QString aFile = aFFile.arg(QString::number(j).rightJustify(8, '0'));
-         aCommands.append(QString("ln -s %1 %2").arg(aCurFile).arg(aFile));
-       }
-       system(aCommands.join(" ; \\\n").latin1());
-       aStartIndex = anEndIndex;
+        anEndIndex = anIndexList[i];
+        QString aCurFile = aFFile.arg(QString::number(aStartIndex).rightJustified(8, '0'));
+        QStringList aCommands;
+        QString aSeparator;
+        for (int j = aStartIndex+1; j < anEndIndex; j++) {
+          QString aFile = aFFile.arg(QString::number(j).rightJustified(8, '0'));
+#ifndef WIN32
+          aCommands.append(QString("ln -s %1 %2").arg(aCurFile).arg(aFile));
+          aSeparator = QString(" ; \\\n");
+#else
+          aCommands.append(QString("COPY /Y %1 %2 > NUL").arg(QString(aCurFile).replace("/","\\\\")).arg(QString(aFile).replace("/","\\\\")));
+          aSeparator = QString(" & ");
+#endif
+        }
+        system(aCommands.join(aSeparator).toLatin1().data());
+        aStartIndex = anEndIndex;
       }
     }
 
     // make AVI file
-    QString aPattern = aDirPath + QDir::separator() + aBaseName;
+    QString aPattern = aDirPath + "/" + aBaseName;
     aPattern += "_\%08d.jpeg";
 
     QString aCmd = myAVIMaker;
@@ -1467,19 +1533,30 @@ void VISU_TimeAnimation::run()
     aCmd += QString(" -f %1").arg(aFPS);
     // aCmd += QString(" -n %1").arg(aNbFiles);
     aCmd += QString(" -n %1").arg(myFileIndex+1);
-    aCmd += QString(" -j %1").arg(aPattern);
+    aCmd += QString(" -j \"%1\"").arg(aPattern);
     aCmd += " | yuv2lav";
-    aCmd += QString(" -o %1").arg(myDumpPath);
-    system(aCmd.latin1());
+    aCmd += QString(" -o \"%1\"").arg(myDumpPath);
+  #ifdef WIN32
+    aCmd += " -f aA";   
+  #endif
+    system(aCmd.toLatin1().data());
 
     // remove temporary jpeg files
+#ifndef WIN32
     aCmd = "( ";
     aCmd += QString("cd %1").arg(aDirPath);
     aCmd += "; ls";
     aCmd += QString(" | egrep '%1_[0-9]*.jpeg'").arg(aBaseName);
     aCmd += " | xargs rm";
     aCmd += " )";
-    system(aCmd.latin1());
+#else
+  QString tmpFile = QString("_") + aBaseName + "_tempfile";
+  QString diskName = aDirPath.split("/")[0];
+  aCmd = diskName + " && (cd " + aDirPath.replace("/","\\\\") + 
+    " && ((dir /b | findstr " + aBaseName + "_[0-9]*.jpeg > " + tmpFile + 
+    ") & (for /f %i in (" + tmpFile + ") do (del \"%i\")) & (del " + tmpFile + "))) > NUL";
+#endif
+    system(aCmd.toLatin1().data());
   }
 
   if (myExecutionState->IsActive())
@@ -1505,7 +1582,7 @@ double VISU_TimeAnimation::getTimeValue (_PTR(SObject) theTimeStamp)
   if (theTimeStamp->FindAttribute(anAttr, "AttributeName")) {
     _PTR(AttributeName) aName (anAttr);
     QString aNameString (aName->Value().c_str());
-    int time_len = aNameString.find(',');
+    int time_len = aNameString.indexOf(',');
     if (time_len > -1)
       return aNameString.left(time_len).toDouble();
     else
@@ -1529,7 +1606,7 @@ void VISU_TimeAnimation::setAnimationSequence(const char* theSequence)
 //------------------------------------------------------------------------
 char* VISU_TimeAnimation::getAnimationSequence()
 {
-  return (char*)mySequence.latin1();
+  return strdup( mySequence.toLatin1().data() );
 }
 
 //------------------------------------------------------------------------
@@ -1539,13 +1616,13 @@ CORBA::Boolean VISU_TimeAnimation::isSequenceDefined()
 }
 
 //------------------------------------------------------------------------
-bool VISU_TimeAnimation::getIndicesFromSequence( QString theSequence, QValueList<long>& theIndices )
+bool VISU_TimeAnimation::getIndicesFromSequence( QString theSequence, QList<long>& theIndices )
 {
   bool isCorrect = true;
 
   theIndices.clear();
 
-  QStringList aList = QStringList::split( ",", theSequence );
+  QStringList aList = theSequence.split( ",", QString::SkipEmptyParts );
   QStringList::iterator it = aList.begin();
   QStringList::iterator itEnd = aList.end();
   for( ; it != itEnd; ++it )
@@ -1574,18 +1651,18 @@ bool VISU_TimeAnimation::getIndicesFromSequence( QString theSequence, QValueList
       ok = false;
       int aLeftIndex = aLeftIndexStr.toLong( &ok );
       if( !ok )
-       continue;
+        continue;
 
       ok = false;
       int aRightIndex = aRightIndexStr.toLong( &ok );
       if( !ok )
-       continue;
+        continue;
 
       if( aLeftIndex >= aRightIndex )
-       continue;
+        continue;
 
       for( int i = aLeftIndex; i <= aRightIndex; i++ )
-       theIndices.append( i );
+        theIndices.append( i );
 
       isCorrect = true;
     }
@@ -1598,27 +1675,39 @@ bool VISU_TimeAnimation::getIndicesFromSequence( QString theSequence, QValueList
 std::string VISU_TimeAnimation::setDumpFormat(const char* theFormat)
 {
   myDumpFormat = theFormat;
-  QStrList aDumpFormats = QImageIO::outputFormats();
+  QList<QByteArray> aDumpFormats = QImageWriter::supportedImageFormats();
   if (myDumpFormat.isEmpty() || 
-      (aDumpFormats.find(theFormat) < 0 && myDumpFormat.compare("AVI") != 0)) {
-    if (aDumpFormats.find("JPEG"))
+      (aDumpFormats.indexOf(theFormat) < 0 && myDumpFormat.compare("AVI") != 0)) {
+    if (aDumpFormats.indexOf("JPEG") >= 0 ||
+        aDumpFormats.indexOf("jpeg") >= 0)
       myDumpFormat = "JPEG";
     else
       myDumpFormat = aDumpFormats.at(0);
   }
-  return myDumpFormat.latin1();
+  return myDumpFormat.toLatin1().data();
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::setTimeStampFrequency(CORBA::Long theFrequency)
+{
+  myTimeStampFrequency = theFrequency;
 }
 
 //------------------------------------------------------------------------
 bool VISU_TimeAnimation::checkAVIMaker() const
 {
-  QStrList aDumpFormats = QImageIO::outputFormats();
-  if (aDumpFormats.find("JPEG") < 0) return false;
+  QList<QByteArray> aDumpFormats = QImageWriter::supportedImageFormats();
+  if (aDumpFormats.indexOf("JPEG") < 0 &&
+      aDumpFormats.indexOf("jpeg") < 0)
+    return false;
 
-  QString aCmd("which ");
-  aCmd += myAVIMaker;
-  aCmd += " >& /dev/null";
-  int iErr = system(aCmd.latin1());
+  QString aCmd;
+#ifndef WIN32
+  aCmd = "which " + myAVIMaker + " 2> /dev/null";
+#else
+  aCmd = "setlocal & set P2=.;%PATH% & (for %e in (%PATHEXT%) do @for %i in (" + myAVIMaker + "%e) do @if NOT \"%~$P2:i\"==\"\" exit /b 0) & exit /b 1";
+#endif
+  int iErr = system(aCmd.toLatin1().data());
   return (iErr == 0);
 }
 
@@ -1646,6 +1735,9 @@ std::string GetPresentationComment (VISU::VISUType thePrsType)
   case VISU::TCUTLINES:
     aPrsCmt = VISU::CutLines_i::myComment;
     break;
+  case VISU::TCUTSEGMENT:
+    aPrsCmt = VISU::CutSegment_i::myComment;
+    break;
   case VISU::TPLOT3D:
     aPrsCmt = VISU::Plot3D_i::myComment;
     break;
@@ -1662,7 +1754,8 @@ std::string GetPresentationComment (VISU::VISUType thePrsType)
     aPrsCmt = VISU::GaussPoints_i::myComment;
     break;
   case VISU::TSCALARMAPONDEFORMEDSHAPE:
-    aPrsCmt = VISU::ScalarMapOnDeformedShape_i::myComment;
+  case VISU::TDEFORMEDSHAPEANDSCALARMAP:
+    aPrsCmt = VISU::DeformedShapeAndScalarMap_i::myComment;
     break;
   default:
     aPrsCmt = "Unknown presentation";
@@ -1674,8 +1767,13 @@ std::string GetPresentationComment (VISU::VISUType thePrsType)
 //------------------------------------------------------------------------
 SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
 {
-  if (myStudy->GetProperties()->IsLocked())
+  if (myStudy->GetProperties()->IsLocked()) {
+    SUIT_MessageBox::warning(0,
+                             QObject::tr("WRN_VISU_WARNING"),
+                             QObject::tr("WRN_STUDY_LOCKED"),
+                             QObject::tr("BUT_OK"));
     return SALOMEDS::SObject::_nil();
+  }
 
   _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
   aStudyBuilder->NewCommand();  // There is a transaction
@@ -1685,18 +1783,18 @@ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
   QString aComment;
   aComment.sprintf("myComment=ANIMATION;myTimeMinVal=%g;myTimeMaxVal=%g;mySequence=%s;myMode=%d",
                    myTimeMinVal,
-                  myTimeMaxVal,
-                  mySequence.latin1(),
-                  myAnimationMode);
+                   myTimeMaxVal,
+                   mySequence.toLatin1().data(),
+                   myAnimationMode);
 
   string anEntry = VISU::CreateAttributes(myStudy,
-                                         aSComponentEntry.c_str(),
-                                         VISU::NO_ICON,
-                                         VISU::NO_IOR,
-                                          GenerateName(),
-                                         VISU::NO_PERFSITENT_REF,
-                                         aComment,
-                                         true);
+                                          aSComponentEntry.c_str(),
+                                          VISU::NO_ICON,
+                                          VISU::NO_IOR,
+                                          GenerateName().toLatin1().data(),
+                                          VISU::NO_PERFSITENT_REF,
+                                          aComment.toLatin1().data(),
+                                          true);
   myAnimEntry = anEntry.c_str();
   _PTR(SObject) aAnimSObject = myStudy->FindObjectID(anEntry.c_str());
 
@@ -1714,20 +1812,20 @@ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
       string aPrsComment = strOut.str();
       string aPrsMyComment = aData.myPrs[0]->GetComment();
       if(aPrsMyComment == "PRSMERGER")
-       aPrsMyComment = "SCALARMAP";
+        aPrsMyComment = "SCALARMAP";
       VISU::CreateAttributes(myStudy, 
-                            newObj->GetID().c_str(),
-                            VISU::NO_ICON,
-                            VISU::NO_IOR,
-                            aPrsMyComment.c_str(),
-                            VISU::NO_PERFSITENT_REF,
-                            aPrsComment.c_str(),
-                            true);
+                             newObj->GetID().c_str(),
+                             VISU::NO_ICON,
+                             VISU::NO_IOR,
+                             aPrsMyComment.c_str(),
+                             VISU::NO_PERFSITENT_REF,
+                             aPrsComment.c_str(),
+                             true);
     }
   }
   aStudyBuilder->CommitCommand();
 
-  return VISU::GetSObject(aAnimSObject);
+  return VISU::GetSObject(aAnimSObject)._retn();
 }
 
 //------------------------------------------------------------------------
@@ -1736,7 +1834,7 @@ void VISU_TimeAnimation::saveAnimation()
   if (myStudy->GetProperties()->IsLocked()) return;
   if (myAnimEntry.isEmpty()) return;
 
-  _PTR(SObject) aAnimSObject = myStudy->FindObjectID(myAnimEntry.latin1());
+  _PTR(SObject) aAnimSObject = myStudy->FindObjectID(myAnimEntry.toLatin1().data());
   if (!aAnimSObject) return;
 
   _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
@@ -1747,14 +1845,14 @@ void VISU_TimeAnimation::saveAnimation()
   QString aComment;
   aComment.sprintf("myComment=ANIMATION;myTimeMinVal=%g;myTimeMaxVal=%g;mySequence=%s;myMode=%d",
                    myTimeMinVal,
-                  myTimeMaxVal,
-                  mySequence.latin1(),
-                  myAnimationMode);
+                   myTimeMaxVal,
+                   mySequence.toLatin1().data(),
+                   myAnimationMode);
 
   _PTR(GenericAttribute) anAttr;
   anAttr = aStudyBuilder->FindOrCreateAttribute(aAnimSObject, "AttributeString");
   _PTR(AttributeString) aCmnt (anAttr);
-  aCmnt->SetValue(aComment.latin1());
+  aCmnt->SetValue(aComment.toLatin1().data());
 
   _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
   int i = 0, nbf = getNbFields();
@@ -1789,13 +1887,13 @@ void VISU_TimeAnimation::saveAnimation()
 
     } else {
       VISU::CreateAttributes(myStudy, 
-                            aRefObj->GetID().c_str(),
-                            VISU::NO_ICON,
-                            VISU::NO_IOR,
+                             aRefObj->GetID().c_str(),
+                             VISU::NO_ICON,
+                             VISU::NO_IOR,
                              aPrsNameTxt.c_str(),
-                            VISU::NO_PERFSITENT_REF,
-                            aPrsComment.c_str(),
-                            true);
+                             VISU::NO_PERFSITENT_REF,
+                             aPrsComment.c_str(),
+                             true);
     }
   }
   aStudyBuilder->CommitCommand();
@@ -1826,9 +1924,15 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
   for (anIter->Init(); anIter->More(); anIter->Next()) {
     _PTR(SObject) aRefObj = anIter->Value();
     _PTR(SObject) aFieldObj;
+
     if (!aRefObj->ReferencedObject(aFieldObj) ) 
       continue;
 
+    int nbAttr = aFieldObj->GetAllAttributes().size();
+    //std::string name1 = aFieldObj->GetName();
+    if(nbAttr<1)
+      continue;
+
     addField(aFieldObj);
     if ( isRangeDefined() || isSequenceDefined() ) 
       myFieldsAbsFrames.pop_back();
@@ -1856,6 +1960,8 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
       aData.myPrsType = VISU::TCUTPLANES;
     else if (strName == VISU::CutLines_i::myComment.c_str())
       aData.myPrsType = VISU::TCUTLINES;
+    else if (strName == VISU::CutSegment_i::myComment.c_str())
+      aData.myPrsType = VISU::TCUTSEGMENT;
     else if (strName == VISU::Plot3D_i::myComment.c_str())
       aData.myPrsType = VISU::TPLOT3D;
     else if (strName == VISU::DeformedShape_i::myComment.c_str())
@@ -1866,8 +1972,8 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
       aData.myPrsType = VISU::TSTREAMLINES;
     else if (strName == VISU::GaussPoints_i::myComment.c_str())
       aData.myPrsType = VISU::TGAUSSPOINTS;
-    else if (strName == VISU::ScalarMapOnDeformedShape_i::myComment.c_str())
-      aData.myPrsType = VISU::TSCALARMAPONDEFORMEDSHAPE;
+    else if (strName == VISU::DeformedShapeAndScalarMap_i::myComment.c_str())
+      aData.myPrsType = VISU::TDEFORMEDSHAPEANDSCALARMAP;
     else
       continue;
     generatePresentations(getNbFields()-1);
@@ -1881,13 +1987,25 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
     }
     for (int i = 1; i < aData.myNbFrames; i++) {
       if (!aData.myPrs[0])
-       continue;
+        continue;
       bool anIsFixedRange = false;
       if (aData.myPrsType != VISU::TGAUSSPOINTS) {
-       if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
-         anIsFixedRange = aPrs->IsRangeFixed();
+        if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
+          anIsFixedRange = aPrs->IsRangeFixed();
+      }
+      if (aData.myPrsType == VISU::TDEFORMEDSHAPEANDSCALARMAP) {
+        if (VISU::DeformedShapeAndScalarMap_i* aDeformedPrs =
+            dynamic_cast<VISU::DeformedShapeAndScalarMap_i*>(aData.myPrs[i])) {
+          //Set correct time stamp number
+          int aTimeStampNum = aDeformedPrs->GetScalarTimeStampNumber();
+          aDeformedPrs->SameAs(aData.myPrs[0]);
+          aDeformedPrs->SetScalarField(aDeformedPrs->GetScalarEntity(),
+                                       aDeformedPrs->GetScalarFieldName(),
+                                       aTimeStampNum);
+        }
       }
-      aData.myPrs[i]->SameAs(aData.myPrs[0]);
+      else
+        aData.myPrs[i]->SameAs(aData.myPrs[0]);
     }
   }
   string aStr = aAnimSObject->GetID();
@@ -1897,6 +2015,7 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
 void VISU_TimeAnimation::onViewDeleted()
 {
   myView = 0;
+  stopAnimation();
 }
 
 void VISU_TimeAnimation::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs)
@@ -1908,24 +2027,24 @@ void VISU_TimeAnimation::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredP
 
   if ( !aPrs_i ) 
     THROW_SALOME_CORBA_EXCEPTION("Error : invalid dynamic cast of the given presentation to VISU::ColoredPrs3d_i",
-                                SALOME::INTERNAL_ERROR);
+                                 SALOME::INTERNAL_ERROR);
   
   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
     FieldData& aData = myFieldsLst[theFieldNum];
     
     if ( aData.myPrs.empty() )
       THROW_SALOME_CORBA_EXCEPTION("Error : presentations for the given field is not yet created!",
-                                  SALOME::INTERNAL_ERROR);
+                                   SALOME::INTERNAL_ERROR);
     
     if ( aPrs_i->GetCResult() != aData.myPrs[0]->GetCResult() )
       THROW_SALOME_CORBA_EXCEPTION("Error : the MED file is not the same!",
-                                  SALOME::INTERNAL_ERROR);
+                                   SALOME::INTERNAL_ERROR);
     
     for (int i = 0; i < aData.myNbFrames; i++) {
       bool anIsFixedRange = false;
       if (aData.myPrsType != VISU::TGAUSSPOINTS) {
-       if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
-         anIsFixedRange = aPrs->IsRangeFixed();
+        if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
+          anIsFixedRange = aPrs->IsRangeFixed();
       }
       aData.myPrs[i]->SameAs(aPrs_i);
     }
@@ -1935,11 +2054,11 @@ void VISU_TimeAnimation::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredP
       FieldData& aData = myFieldsLst[f];
       
       if ( aData.myPrs.empty() )
-       THROW_SALOME_CORBA_EXCEPTION("Error : presentations for the given field is not yet created!",
-                                    SALOME::INTERNAL_ERROR);
+        THROW_SALOME_CORBA_EXCEPTION("Error : presentations for the given field is not yet created!",
+                                     SALOME::INTERNAL_ERROR);
       
       for (int i = 0; i < aData.myNbFrames; i++) {
-       aData.myPrs[i]->SameAs(aPrs_i);
+        aData.myPrs[i]->SameAs(aPrs_i);
       }
     }
   }
@@ -1967,10 +2086,10 @@ struct TNewAnimationEvent: public SALOME_Event
   Execute()
   {
     SUIT_Session* aSession = SUIT_Session::session();
-    QPtrList<SUIT_Application> anApplications = aSession->applications();
-    QPtrListIterator<SUIT_Application> anIter (anApplications);
-    while (SUIT_Application* anApp = anIter.current()) {
-      ++anIter;
+    QList<SUIT_Application*> anApplications = aSession->applications();
+    QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
+    while ( anIter !=  anApplications.end() ) {
+      SUIT_Application* anApp = *anIter;
       if (SUIT_Study* aSStudy = anApp->activeStudy()) {
         if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
           if (_PTR(Study) aCStudy = aStudy->studyDS()) {
@@ -1981,6 +2100,7 @@ struct TNewAnimationEvent: public SALOME_Event
           }
         }
       }
+      anIter++;
     }
   }
 };
@@ -2177,6 +2297,16 @@ char* VISU_TimeAnimation_i::setDumpFormat (const char* theFormat)
   return CORBA::string_dup(aDumpFormat.c_str());
 }
 
+void VISU_TimeAnimation_i::setTimeStampFrequency(CORBA::Long theFrequency)
+{
+  myAnim->setTimeStampFrequency(theFrequency);
+}
+
+CORBA::Long VISU_TimeAnimation_i::getTimeStampFrequency()
+{
+  return myAnim->getTimeStampFrequency();
+}
+
 CORBA::Boolean VISU_TimeAnimation_i::isCycling()
 {
   return myAnim->isCycling();