Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / VISU_I / VISU_TimeAnimation.cxx
index 0c24e562b3409788af4c94e4b5d62900c3b4f864..fa5befe56612e2e7a1d87990af36ba8a806ffc4e 100644 (file)
 #include "VISU_ScalarMap_i.hh"
 #include "VISU_IsoSurfaces_i.hh"
 #include "VISU_DeformedShape_i.hh"
+#include "VISU_ScalarMapOnDeformedShape_i.hh"
 #include "VISU_CutPlanes_i.hh"
 #include "VISU_Plot3D_i.hh"
 #include "VISU_CutLines_i.hh"
 #include "VISU_Vectors_i.hh"
 #include "VISU_StreamLines_i.hh"
+#include "VISU_GaussPoints_i.hh"
 #include "VISU_ViewManager_i.hh"
 #include "VISU_View_i.hh"
 
 #include "SALOMEDSClient_AttributeName.hxx"
 
 #include <qpixmap.h>
+#include <qimage.h>
+#include <qstrlist.h>
 
 using namespace std;
 
 
-//************************************************************************
+//------------------------------------------------------------------------
 VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
                                         VISU::View3D_ptr theView3D)
 {
@@ -60,11 +64,12 @@ 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 = VISU::GetViewWindow(aVW);
+    myView = dynamic_cast<SVTK_ViewWindow*>(aVW);
+    connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) );
   }
 
-  myMaxVal = 0;
-  myMinVal = 0;
+  myTimeMinVal = 0;
+  myTimeMaxVal = 0;
   myTimeMin = 0;
   myTimeMax = 0;
   myLastError = "";
@@ -74,16 +79,21 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
 }
 
 
-//************************************************************************
+//------------------------------------------------------------------------
 VISU_TimeAnimation::~VISU_TimeAnimation()
 {
+  if (!myView) {
+    MESSAGE("Viewer is not defined for animation");
+    return;
+  }
+
   for (int i = 0; i < getNbFields(); i++) {
     clearData(myFieldsLst[i]);
   }
 }
 
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::addField (_PTR(SObject) theField)
 {
   FieldData aNewData;
@@ -106,7 +116,7 @@ void VISU_TimeAnimation::addField (_PTR(SObject) theField)
   }
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField)
 {
   SALOMEDS::SObject_var theFieldDup = SALOMEDS::SObject::_duplicate(theField);
@@ -115,15 +125,18 @@ void VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField)
 }
 
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::clearData(FieldData& theData) {
+  if (!myView) {
+    MESSAGE("Viewer is not defined for animation");
+    return;
+  }
   theData.myTiming.clear();
   vtkRenderer* aRen = myView->getRenderer();
   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]->Delete();
       }
     }
     theData.myActors.clear();
@@ -140,146 +153,179 @@ void VISU_TimeAnimation::clearData(FieldData& theData) {
 }
 
 
-//************************************************************************
+namespace
+{
+  //------------------------------------------------------------------------
+  template<class TPrs3d>
+  void
+  GeneratePresentations(_PTR(Study) theStudy,
+                       FieldData& theData,
+                       VISU::Result_i* theResult,
+                       bool theIsRangeDefined,
+                       CORBA::Double theTimeMin,
+                       CORBA::Double theTimeMax)
+  {
+    double aMin = VTK_LARGE_FLOAT, aMax = -VTK_LARGE_FLOAT;
+
+    _PTR(ChildIterator) anIter = theStudy->NewChildIterator(theData.myField);
+    anIter->Next(); // First is reference on support
+
+    long aFrameId = 0;
+    for(; anIter->More(); anIter->Next()){
+      if (aFrameId == theData.myNbTimes) {
+       MESSAGE("There are extra timestamps in field");
+       return;
+      }
+      _PTR(SObject) aTimeStamp = anIter->Value();
+      if(!aTimeStamp) 
+       continue;
+
+      theData.myTiming[aFrameId] = VISU_TimeAnimation::getTimeValue(aTimeStamp);
+      if (theIsRangeDefined) {
+       if (theData.myTiming[aFrameId] < theTimeMin) 
+         continue;
+       if (theData.myTiming[aFrameId] > theTimeMax) 
+         break;
+      }
+
+      VISU::Storable::TRestoringMap aTimeMap = VISU_TimeAnimation::getMapOfValue(aTimeStamp);
+      QString aMeshName = VISU::Storable::FindValue(aTimeMap,"myMeshName");
+      VISU::Entity anEntity = (VISU::Entity) VISU::Storable::FindValue(aTimeMap,"myEntityId").toInt();
+      QString aFieldName = VISU::Storable::FindValue(aTimeMap,"myFieldName");
+      int aTimeStampId = VISU::Storable::FindValue(aTimeMap,"myTimeStampId").toInt();
+      
+      TPrs3d* aPresent = new TPrs3d(theResult, false);
+      aPresent->Create(aMeshName.latin1(), anEntity,
+                      aFieldName.latin1(), aTimeStampId);
+      theData.myPrs[aFrameId++] = aPresent;
+
+      aMin = std::min(aPresent->GetMin(), aMin);
+      aMax = std::max(aPresent->GetMax(), aMax);
+    }
+    theData.myNbFrames = aFrameId;
+
+    if (theData.myPrsType != VISU::TGAUSSPOINTS){
+      int aRangeType = VISU::GetResourceMgr()->integerValue("VISU" , "scalar_range_type", 0);
+      if( aRangeType != 1 ){
+       for(long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++) {
+         if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(theData.myPrs[aFrameId])){
+           aPrs->SetRange(aMin, aMax);
+           aPrs->SetOffset(theData.myOffset);
+         }
+       }
+      }
+      if (theData.myPrsType == VISU::TISOSURFACE)
+       for (long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++)
+         if (VISU::IsoSurfaces_i* aPrs = dynamic_cast<VISU::IsoSurfaces_i*>(theData.myPrs[aFrameId]))
+           aPrs->SetSubRange(aMin, aMax);
+    }
+  }
+}
+  
 void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) {
   FieldData& aData = myFieldsLst[theFieldNum];
 
   // Delete previous presentations
   clearData(aData);
 
-  VISU::Result_i* pResult = createPresent(aData.myField);
+  VISU::Result_i* aResult = createPresent(aData.myField);
   VISU::Storable::TRestoringMap aMap = getMapOfValue(aData.myField);
   aData.myNbFrames = aData.myNbTimes;
-    //VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
+  //VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
 
   aData.myPrs.resize(aData.myNbTimes,NULL);
   aData.myTiming.resize(aData.myNbTimes);
 
-  _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aData.myField);
-  _PTR(SObject) aTimeStamp;
-  anIter->Next(); // First is reference on support
-  long i = 0;
-  double aMin = VTK_LARGE_FLOAT, aMax = -VTK_LARGE_FLOAT;
-  for (; anIter->More(); anIter->Next()) {
-    if (i == aData.myNbTimes) {
-      MESSAGE("There are extra timestamps in field");
-      return;
-    }
-    aTimeStamp = anIter->Value();
-    if (!aTimeStamp) continue;
-
-    aData.myTiming[i] = getTimeValue(aTimeStamp);
-    if (isRangeDefined()) {
-      if (aData.myTiming[i] < myMinVal) continue;
-      if (aData.myTiming[i] > myMaxVal) break;
-    }
-
-    VISU::Storable::TRestoringMap aTimeMap = getMapOfValue(aTimeStamp);
-    QString aMeshName = VISU::Storable::FindValue(aTimeMap,"myMeshName");
-    VISU::Entity anEntity = (VISU::Entity) VISU::Storable::FindValue(aTimeMap,"myEntityId").toInt();
-    QString aFieldName = VISU::Storable::FindValue(aTimeMap,"myFieldName");
-    int aTimeStampId = VISU::Storable::FindValue(aTimeMap,"myTimeStampId").toInt();
-
-    switch (aData.myPrsType) {
-    case VISU::TSCALARMAP: // ScalarMap
-      {
-       VISU::ScalarMap_i* aPresent = new VISU::ScalarMap_i(pResult, false);
-       aPresent->Create(aMeshName.latin1(), anEntity,
-                        aFieldName.latin1(), aTimeStampId);
-       //VISU::ScalarMap_var aTmp = aPresent->_this();
-       //aPresent->_remove_ref();
-       aData.myPrs[i] = aPresent;
-      }
-      break;
-
-    case VISU::TISOSURFACE: // Iso Surfaces
-      {
-       VISU::IsoSurfaces_i* aPresent = new VISU::IsoSurfaces_i(pResult, false);
-       aPresent->Create(aMeshName.latin1(), anEntity,
-                        aFieldName.latin1(), aTimeStampId);
-       //VISU::IsoSurfaces_var aTmp = aPresent->_this();
-       //aPresent->_remove_ref();
-       aData.myPrs[i] = aPresent;
-      }
-      break;
-
-    case VISU::TCUTPLANES: // Cut Planes
-      {
-       VISU::CutPlanes_i* aPresent = new VISU::CutPlanes_i(pResult, false);
-       aPresent->Create(aMeshName.latin1(), anEntity,
-                        aFieldName.latin1(), aTimeStampId);
-       //VISU::CutPlanes_var aTmp = aPresent->_this();
-       //aPresent->_remove_ref();
-       aData.myPrs[i] = aPresent;
-      }
-      break;
-
-    case VISU::TPLOT3D: // Plot3d
-      {
-       VISU::Plot3D_i* aPresent = new VISU::Plot3D_i (pResult, false);
-       aPresent->Create(aMeshName.latin1(), anEntity,
-                        aFieldName.latin1(), aTimeStampId);
-       aData.myPrs[i] = aPresent;
-      }
-      break;
-
-    case VISU::TDEFORMEDSHAPE: // Deformed Shape
-      {
-       VISU::DeformedShape_i* aPresent = new VISU::DeformedShape_i(pResult, false);
-       aPresent->Create(aMeshName.latin1(), anEntity,
-                        aFieldName.latin1(), aTimeStampId);
-       //VISU::DeformedShape_var aTmp = aPresent->_this();
-       //aPresent->_remove_ref();
-       aData.myPrs[i] = aPresent;
-      }
-      break;
-
-    case VISU::TVECTORS: // Vectors
-      {
-       VISU::Vectors_i* aPresent = new VISU::Vectors_i(pResult, false);
-       aPresent->Create(aMeshName.latin1(), anEntity,
-                        aFieldName.latin1(), aTimeStampId);
-       //VISU::Vectors_var aTmp = aPresent->_this();
-       //aPresent->_remove_ref();
-       aData.myPrs[i] = aPresent;
-      }
-      break;
-
-    case VISU::TSTREAMLINES: // Stream Lines
-      {
-       VISU::StreamLines_i* aPresent = new VISU::StreamLines_i(pResult, false);
-       aPresent->Create(aMeshName.latin1(), anEntity,
-                        aFieldName.latin1(), aTimeStampId);
-       //VISU::StreamLines_var aTmp = aPresent->_this();
-       //aPresent->_remove_ref();
-       aData.myPrs[i] = aPresent;
-      }
-      break;
-    default:
-      MESSAGE("Not implemented for this presentation type: " << aData.myPrsType);
-      return;
-    }
-    if (aData.myPrs[i]->GetMin() < aMin) aMin = aData.myPrs[i]->GetMin();
-    if (aData.myPrs[i]->GetMax() > aMax) aMax = aData.myPrs[i]->GetMax();
-    i++;
-  }
-  aData.myNbFrames = i;
-
-  int rangeType = VISU::GetResourceMgr()->integerValue("VISU" , "scalar_range_type", 0);
-  if ( rangeType != 1 ) {
-    for (i = 0; i < aData.myNbFrames; i++) {
-      aData.myPrs[i]->SetRange(aMin, aMax);
-      aData.myPrs[i]->SetOffset(aData.myOffset);
-    }
-    if (aData.myPrsType == VISU::TISOSURFACE)
-      for (i = 0; i < aData.myNbFrames; i++)
-       if (VISU::IsoSurfaces_i* aPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aData.myPrs[i]))
-          aPrs->SetSubRange(aMin, aMax);
+  using namespace VISU;
+  switch (aData.myPrsType) {
+  case VISU::TSCALARMAP: // ScalarMap
+    GeneratePresentations<ScalarMap_i>(myStudy,
+                                      aData,
+                                      aResult,
+                                      isRangeDefined(),
+                                      myTimeMinVal,
+                                      myTimeMaxVal);
+    break;
+  case VISU::TISOSURFACE: // Iso Surfaces
+    GeneratePresentations<IsoSurfaces_i>(myStudy,
+                                        aData,
+                                        aResult,
+                                        isRangeDefined(),
+                                        myTimeMinVal,
+                                        myTimeMaxVal);
+    break;
+  case VISU::TCUTPLANES: // Cut Planes
+    GeneratePresentations<CutPlanes_i>(myStudy,
+                                      aData,
+                                      aResult,
+                                      isRangeDefined(),
+                                      myTimeMinVal,
+                                      myTimeMaxVal);
+    break;
+  case VISU::TCUTLINES: // Cut Lines
+    GeneratePresentations<CutLines_i>(myStudy,
+                                     aData,
+                                     aResult,
+                                     isRangeDefined(),
+                                     myTimeMinVal,
+                                     myTimeMaxVal);
+    break;
+  case VISU::TPLOT3D: // Plot3d
+    GeneratePresentations<Plot3D_i>(myStudy,
+                                   aData,
+                                   aResult,
+                                   isRangeDefined(),
+                                   myTimeMinVal,
+                                   myTimeMaxVal);
+    break;
+  case VISU::TDEFORMEDSHAPE: // Deformed Shape
+    GeneratePresentations<DeformedShape_i>(myStudy,
+                                          aData,
+                                          aResult,
+                                          isRangeDefined(),
+                                          myTimeMinVal,
+                                          myTimeMaxVal);
+    break;
+  case VISU::TVECTORS: // Vectors
+    GeneratePresentations<Vectors_i>(myStudy,
+                                    aData,
+                                    aResult,
+                                    isRangeDefined(),
+                                    myTimeMinVal,
+                                    myTimeMaxVal);
+    break;
+  case VISU::TSTREAMLINES: // Stream Lines
+    GeneratePresentations<StreamLines_i>(myStudy,
+                                        aData,
+                                        aResult,
+                                        isRangeDefined(),
+                                        myTimeMinVal,
+                                        myTimeMaxVal);
+    break;
+  case VISU::TGAUSSPOINTS: // Gauss Points
+    GeneratePresentations<GaussPoints_i>(myStudy,
+                                        aData,
+                                        aResult,
+                                        isRangeDefined(),
+                                        myTimeMinVal,
+                                        myTimeMaxVal);
+    break;
+  case VISU::TSCALARMAPONDEFORMEDSHAPE: // Scalar map on deformed shape
+    GeneratePresentations<ScalarMapOnDeformedShape_i>(myStudy,
+                                                     aData,
+                                                     aResult,
+                                                     isRangeDefined(),
+                                                     myTimeMinVal,
+                                                     myTimeMaxVal);
+    break;
+  default:
+    MESSAGE("Not implemented for this presentation type: " << aData.myPrsType);
+    return;
   }
 }
 
 
-//************************************************************************
+//------------------------------------------------------------------------
 CORBA::Boolean VISU_TimeAnimation::generateFrames() {
   if (!myView) {
     MESSAGE("Viewer is not defined for animation");
@@ -318,7 +364,7 @@ CORBA::Boolean VISU_TimeAnimation::generateFrames() {
   return aNoError;
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::clearView() {
   if (!myView) {
     MESSAGE("Viewer is not defined for animation");
@@ -331,7 +377,6 @@ void VISU_TimeAnimation::clearView() {
       for (int i = 0, iEnd = aData.myActors.size(); i < iEnd; i++) {
        if (aData.myActors[i] != 0) {
          aData.myActors[i]->RemoveFromRender(aRen);
-         aData.myActors[i]->Delete();
        }
       }
       aData.myActors.clear();
@@ -340,12 +385,12 @@ void VISU_TimeAnimation::clearView() {
   VISU::RepaintView(myView);
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::stopAnimation() {
   myIsActive = false;
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::startAnimation() {
   if (!myIsActive) {
     myIsActive = true;
@@ -353,8 +398,12 @@ void VISU_TimeAnimation::startAnimation() {
   }
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::nextFrame() {
+  if (!myView) {
+    MESSAGE("Viewer is not defined for animation");
+    return;
+  }
   stopAnimation();
   if (myFrame < (myFieldsLst[0].myNbFrames-1)) {
     int i;
@@ -372,8 +421,12 @@ void VISU_TimeAnimation::nextFrame() {
   }
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::prevFrame() {
+  if (!myView) {
+    MESSAGE("Viewer is not defined for animation");
+    return;
+  }
   stopAnimation();
   if (myFrame > 0) {
     int i;
@@ -391,8 +444,12 @@ void VISU_TimeAnimation::prevFrame() {
   }
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::firstFrame() {
+  if (!myView) {
+    MESSAGE("Viewer is not defined for animation");
+    return;
+  }
   stopAnimation();
   int i;
   for (i = 0; i < getNbFields(); i++)
@@ -410,8 +467,12 @@ void VISU_TimeAnimation::firstFrame() {
   }
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::lastFrame() {
+  if (!myView) {
+    MESSAGE("Viewer is not defined for animation");
+    return;
+  }
   stopAnimation();
   int i;
   for (i = 0; i < getNbFields(); i++)
@@ -428,9 +489,13 @@ void VISU_TimeAnimation::lastFrame() {
 }
 
 
-//************************************************************************
+//------------------------------------------------------------------------
 // For Batchmode using
 void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame) {
+  if (!myView) {
+    MESSAGE("Viewer is not defined for animation");
+    return;
+  }
   if ((theFrame < 0) || (theFrame > (getNbFrames()-1)))
     return;
   stopAnimation();
@@ -454,23 +519,23 @@ void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame) {
 }
 
 
-//************************************************************************
-VISU::ScalarMap_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CORBA::Long theFrame) {
+//------------------------------------------------------------------------
+VISU::ColoredPrs3d_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CORBA::Long theFrame) {
   if ((theField > getNbFields()) || (theField < 0))
-    return VISU::ScalarMap::_nil();
+    return VISU::ColoredPrs3d::_nil();
   if ((theFrame < 0) || (theFrame > (myFieldsLst[theField].myNbFrames - 1)))
-    return VISU::ScalarMap::_nil();
+    return VISU::ColoredPrs3d::_nil();
   return myFieldsLst[theField].myPrs[theFrame]->_this();
 }
 
 
-//************************************************************************
+//------------------------------------------------------------------------
 CORBA::Long VISU_TimeAnimation::getNbFrames() {
   return (getNbFields() > 0)? myFieldsLst[0].myNbFrames : 0;
 }
 
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::run()
 {
   if (!myView) {
@@ -500,42 +565,45 @@ void VISU_TimeAnimation::run()
     }
     myView->Repaint(false);
 
+    k = 1;
+    if (myProportional) {
+      switch (myFrame) {
+      case 0:
+        break;
+      case 1:
+        if (myFieldsLst[0].myNbFrames > 2)
+          k = (myFieldsLst[0].myTiming[myFrame+1] -
+               myFieldsLst[0].myTiming[myFrame]) / aOneVal;
+        break;
+      default:
+        if (myFrame < (myFieldsLst[0].myNbFrames - 1))
+          k = (myFieldsLst[0].myTiming[myFrame+1] -
+               myFieldsLst[0].myTiming[myFrame]) / aOneVal;
+      }
+    }
+    int delay = (int)(1000. * k / mySpeed);
+    if (delay < 1 && isDumping) {
+      // We must unlock mutex for some time before grabbing to allow view updating
+      delay = 1;
+    }
+    qApp->unlock();
+    msleep(delay);
+    qApp->lock();
+
     if (isDumping) {
       // We must unlock mutex for some time before grabbing to allow view updating
       qApp->unlock();
       msleep(100);
       qApp->lock();
-
-      QPixmap px = QPixmap::grabWindow(myView->winId());
       QString aFile(myDumpPath);
       QString aName = QString("%1").arg(myFieldsLst[0].myTiming[myFrame]);
       int aPos = -1;
       while ((aPos = aName.find(".")) > -1 )
        aName.replace(aPos, 1, "_");
       aFile += aName;
-      aFile += ".jpeg";
-      px.save(aFile, "JPEG");
-    } else {
-      k = 1;
-      if (myProportional) {
-       switch (myFrame) {
-       case 0:
-         break;
-       case 1:
-         if (myFieldsLst[0].myNbFrames > 2)
-           k = (myFieldsLst[0].myTiming[myFrame+1] -
-                 myFieldsLst[0].myTiming[myFrame]) / aOneVal;
-         break;
-       default:
-         if (myFrame < (myFieldsLst[0].myNbFrames - 1))
-            k = (myFieldsLst[0].myTiming[myFrame+1] -
-                 myFieldsLst[0].myTiming[myFrame]) / aOneVal;
-       }
-      }
-      int delay = (int)(1000. * k / mySpeed);
-      qApp->unlock();
-      msleep(delay);
-      qApp->lock();
+      aFile += ".";
+      aFile += myDumpFormat.lower();
+      myView->dumpViewToFormat(aFile,myDumpFormat);
     }
 
     if (!myIsActive) break;
@@ -555,7 +623,7 @@ void VISU_TimeAnimation::run()
   QThread::exit();
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 VISU::Result_i* VISU_TimeAnimation::createPresent (_PTR(SObject) theField)
 {
   _PTR(SObject) aSObj = theField->GetFather();
@@ -566,7 +634,7 @@ VISU::Result_i* VISU_TimeAnimation::createPresent (_PTR(SObject) theField)
   return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 VISU::Storable::TRestoringMap VISU_TimeAnimation::getMapOfValue (_PTR(SObject) theSObject)
 {
   VISU::Storable::TRestoringMap aMap;
@@ -582,7 +650,7 @@ VISU::Storable::TRestoringMap VISU_TimeAnimation::getMapOfValue (_PTR(SObject) t
   return aMap;
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 double VISU_TimeAnimation::getTimeValue (_PTR(SObject) theTimeStamp)
 {
   _PTR(GenericAttribute) anAttr;
@@ -598,12 +666,25 @@ double VISU_TimeAnimation::getTimeValue (_PTR(SObject) theTimeStamp)
   return -1.0;
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::setSpeed(CORBA::Long theSpeed)
 {
   mySpeed = (theSpeed<1)? 1 : theSpeed;
 }
 
+std::string VISU_TimeAnimation::setDumpFormat(const char* theFormat)
+{
+  myDumpFormat = theFormat;
+  QStrList aDumpFormats = QImageIO::outputFormats();
+  if (myDumpFormat.isEmpty() || aDumpFormats.find(theFormat) < 0) {
+    if (aDumpFormats.find("JPEG"))
+      myDumpFormat = "JPEG";
+    else
+      myDumpFormat = aDumpFormats.at(0);
+  }
+  return myDumpFormat.latin1();
+}
+
 //************************************************************************
 int VISU_TimeAnimation::myNBAnimations = 0;
 QString VISU_TimeAnimation::GenerateName()
@@ -611,7 +692,7 @@ QString VISU_TimeAnimation::GenerateName()
   return VISU::GenerateName("Animation", myNBAnimations++);
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 std::string GetPresentationComment (VISU::VISUType thePrsType)
 {
   std::string aPrsCmt;
@@ -625,6 +706,9 @@ std::string GetPresentationComment (VISU::VISUType thePrsType)
   case VISU::TCUTPLANES:
     aPrsCmt = VISU::CutPlanes_i::myComment;
     break;
+  case VISU::TCUTLINES:
+    aPrsCmt = VISU::CutLines_i::myComment;
+    break;
   case VISU::TPLOT3D:
     aPrsCmt = VISU::Plot3D_i::myComment;
     break;
@@ -637,6 +721,12 @@ std::string GetPresentationComment (VISU::VISUType thePrsType)
   case VISU::TSTREAMLINES:
     aPrsCmt = VISU::StreamLines_i::myComment;
     break;
+  case VISU::TGAUSSPOINTS:
+    aPrsCmt = VISU::GaussPoints_i::myComment;
+    break;
+  case VISU::TSCALARMAPONDEFORMEDSHAPE:
+    aPrsCmt = VISU::ScalarMapOnDeformedShape_i::myComment;
+    break;
   default:
     aPrsCmt = "Unknown presentation";
     break;
@@ -644,7 +734,7 @@ std::string GetPresentationComment (VISU::VISUType thePrsType)
   return aPrsCmt;
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
 {
   if (myStudy->GetProperties()->IsLocked())
@@ -656,8 +746,8 @@ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
   std::string aSComponentEntry = aSComponent->GetID();
 
   QString aComment;
-  aComment.sprintf("myComment=ANIMATION;myType=%d;myMinVal=%g;myMaxVal=%g",
-                   VISU::TANIMATION,myMinVal,myMaxVal);
+  aComment.sprintf("myComment=ANIMATION;myType=%d;myTimeMinVal=%g;myTimeMaxVal=%g",
+                   VISU::TANIMATION,myTimeMinVal,myTimeMaxVal);
 
   string anEntry = VISU::CreateAttributes(myStudy,aSComponentEntry.c_str(),"","",
                                           GenerateName(),"",aComment,true);
@@ -684,7 +774,7 @@ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
   return VISU::GetSObject(aAnimSObject);
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::saveAnimation()
 {
   if (myStudy->GetProperties()->IsLocked()) return;
@@ -699,8 +789,8 @@ void VISU_TimeAnimation::saveAnimation()
   std::string aSComponentEntry = aSComponent->GetID();
 
   QString aComment;
-  aComment.sprintf("myComment=ANIMATION;myType=%d;myMinVal=%g;myMaxVal=%g",
-                   VISU::TANIMATION,myMinVal,myMaxVal);
+  aComment.sprintf("myComment=ANIMATION;myType=%d;myTimeMinVal=%g;myTimeMaxVal=%g",
+                   VISU::TANIMATION,myTimeMinVal,myTimeMaxVal);
 
   _PTR(GenericAttribute) anAttr;
   anAttr = aStudyBuilder->FindOrCreateAttribute(aAnimSObject, "AttributeComment");
@@ -745,7 +835,7 @@ void VISU_TimeAnimation::saveAnimation()
   aStudyBuilder->CommitCommand();
 }
 
-//************************************************************************
+//------------------------------------------------------------------------
 void VISU_TimeAnimation::restoreFromStudy(SALOMEDS::SObject_ptr theField)
 {
   _PTR(SObject) aAnimSObject = VISU::GetClientSObject(theField, myStudy);
@@ -766,8 +856,8 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
   VISU::Storable::StrToMap(strIn,aMap);
   bool isExist;
 
-  myMinVal = VISU::Storable::FindValue(aMap,"myMinVal",&isExist).toDouble();
-  myMaxVal = VISU::Storable::FindValue(aMap,"myMaxVal",&isExist).toDouble();
+  myTimeMinVal = VISU::Storable::FindValue(aMap,"myTimeMinVal",&isExist).toDouble();
+  myTimeMaxVal = VISU::Storable::FindValue(aMap,"myTimeMaxVal",&isExist).toDouble();
 
   _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
   for (anIter->Init(); anIter->More(); anIter->Next()) {
@@ -793,6 +883,8 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
       aData.myPrsType = VISU::TISOSURFACE;
     else if (strName == VISU::CutPlanes_i::myComment.c_str())
       aData.myPrsType = VISU::TCUTPLANES;
+    else if (strName == VISU::CutLines_i::myComment.c_str())
+      aData.myPrsType = VISU::TCUTLINES;
     else if (strName == VISU::Plot3D_i::myComment.c_str())
       aData.myPrsType = VISU::TPLOT3D;
     else if (strName == VISU::DeformedShape_i::myComment.c_str())
@@ -801,6 +893,10 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
       aData.myPrsType = VISU::TVECTORS;
     else if (strName == VISU::StreamLines_i::myComment.c_str())
       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
       continue;
     generatePresentations(getNbFields()-1);
@@ -825,6 +921,11 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
   myAnimEntry = aStr.c_str();
 }
 
+void VISU_TimeAnimation::onViewDeleted()
+{
+  myView = 0;
+}
+
 
 //========================================================================
 //========================================================================
@@ -962,7 +1063,7 @@ CORBA::Long VISU_TimeAnimation_i::getCurrentFrame()
   return myAnim->getCurrentFrame();
 }
 
-VISU::ScalarMap_ptr VISU_TimeAnimation_i::getPresentation
+VISU::ColoredPrs3d_ptr VISU_TimeAnimation_i::getPresentation
                     (CORBA::Long theField, CORBA::Long theFrame)
 {
   return myAnim->getPresentation(theField,theFrame);
@@ -1020,6 +1121,12 @@ void VISU_TimeAnimation_i::dumpTo (const char* thePath)
   myAnim->dumpTo(thePath);
 }
 
+char* VISU_TimeAnimation_i::setDumpFormat (const char* theFormat)
+{
+  string aDumpFormat = myAnim->setDumpFormat(theFormat);
+  return CORBA::string_dup(aDumpFormat.c_str());
+}
+
 CORBA::Boolean VISU_TimeAnimation_i::isCycling()
 {
   return myAnim->isCycling();