]> SALOME platform Git repositories - modules/visu.git/blob - src/VISU_I/VISU_TimeAnimation.cxx
Salome HOME
IPAL 0051560: wrong dump of visual parameters for displayed curves is generated for...
[modules/visu.git] / src / VISU_I / VISU_TimeAnimation.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  File   : VISU_TimeAnimation.cxx
24 //  Author : Vitaly SMETANNIKOV
25 //  Module : VISU
26 //
27 #include "VISU_TimeAnimation.h"
28
29 #ifdef WNT
30 #include <windows.h>
31 #include <QMessageBox>
32 #endif
33
34 #include "VISUConfig.hh"
35
36 #include "VISU_Result_i.hh"
37 #include "VISU_Prs3d_i.hh"
38 #include "VISU_Mesh_i.hh"
39 #include "VISU_IsoSurfaces_i.hh"
40 #include "VISU_DeformedShape_i.hh"
41 #include "VISU_DeformedShapeAndScalarMap_i.hh"
42 #include "VISU_CutPlanes_i.hh"
43 #include "VISU_Plot3D_i.hh"
44 #include "VISU_CutLines_i.hh"
45 #include "VISU_CutSegment_i.hh"
46 #include "VISU_Vectors_i.hh"
47 #include "VISU_StreamLines_i.hh"
48 #include "VISU_GaussPoints_i.hh"
49 #include "VISU_ViewManager_i.hh"
50 #include "VISU_View_i.hh"
51
52 #include "VISU_ScalarBarActor.hxx"
53 #include "VISU_Actor.h"
54
55 #include "SalomeApp_Study.h"
56
57 #include "SVTK_ViewWindow.h"
58
59 #include "SALOME_Event.h"
60
61 #include "SUIT_ResourceMgr.h"
62 #include "SUIT_Application.h"
63 #include "SUIT_Session.h"
64 #include "SUIT_Study.h"
65 #include "SUIT_MessageBox.h"
66
67 #include "SALOMEDSClient_AttributeString.hxx"
68 #include "SALOMEDSClient_AttributeName.hxx"
69
70 #include "Utils_ExceptHandlers.hxx"
71
72 #include <QPixmap>
73 #include <QImage>
74 #include <QImageWriter>
75 #include <QStringList>
76 #include <QDir>
77
78 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
79 #define NO_CAS_CATCH
80 #endif
81
82 #include <Standard_Failure.hxx>
83
84 #ifdef NO_CAS_CATCH
85 #include <Standard_ErrorHandler.hxx>
86 #endif
87
88 using namespace std;
89
90 //------------------------------------------------------------------------
91 namespace VISU 
92 {
93   //------------------------------------------------------------------------
94   class ExecutionState 
95   {
96     bool myIsActive;
97     QMutex myIsActiveMutex;
98   public:
99     ExecutionState(bool isActive = false)
100       : myIsActive(isActive) {}
101
102     bool IsActive() {
103       bool state;
104       myIsActiveMutex.lock();
105       state = myIsActive;
106       myIsActiveMutex.unlock();
107       return state;
108     }
109     bool SetActive(bool isActive) {
110       bool state;
111       myIsActiveMutex.lock();
112       state = myIsActive;
113       myIsActive = isActive;
114       myIsActiveMutex.unlock();
115       return state;
116     }
117   };
118
119
120   //------------------------------------------------------------------------
121   class DumpPath 
122   {
123     QString myPath;
124     QMutex myPathMutex;
125   public:
126     DumpPath(QString thePath = QString())
127       : myPath(thePath) {}
128
129     QString GetPath() {
130       QString aPath;
131       myPathMutex.lock();
132       aPath = myPath;
133       myPathMutex.unlock();
134       return aPath;
135     }
136     void SetPath(QString thePath) {
137       myPathMutex.lock();
138       myPath = thePath;
139       myPathMutex.unlock();
140     }
141   };
142
143
144   //------------------------------------------------------------------------
145   struct TCompositeMinMaxController : virtual TVTKMinMaxController
146   {
147     typedef ColoredPrs3d_i* TKey;
148     typedef std::map< TKey, VISU::PMinMaxController > TMinMaxContainer;
149     TMinMaxContainer myMinMaxContainer;    
150
151     void
152     AddController(ColoredPrs3d_i* theReference, 
153                   VISU::PMinMaxController theMinMaxController)
154     {
155       myMinMaxContainer[ TKey( theReference ) ] = theMinMaxController;
156     }
157
158     virtual
159     void
160     UpdateReference(ColoredPrs3d_i* theFromPrs3, ColoredPrs3d_i* theToPrs3d)
161     {
162       TMinMaxContainer::iterator anIter = myMinMaxContainer.find( TKey( theFromPrs3 ) );
163       if ( anIter != myMinMaxContainer.end() ) {
164         myMinMaxContainer.erase( anIter );
165         myMinMaxContainer[ TKey( theToPrs3d ) ] = VISU::CreateDefaultMinMaxController( theToPrs3d );      
166       }
167     }
168
169     virtual
170     vtkFloatingPointType
171     GetComponentMin(vtkIdType theCompID)
172     {
173       vtkFloatingPointType aMin = TMinMaxController::GetComponentMin(theCompID);
174       if ( !myMinMaxContainer.empty() ) {
175         TMinMaxContainer::const_iterator anIter = myMinMaxContainer.begin();
176         for(; anIter != myMinMaxContainer.end(); anIter++){
177           VISU::PMinMaxController aMinMaxController = anIter->second;
178           aMin = std::min(aMin, aMinMaxController->GetComponentMin(theCompID));
179         }
180       }
181       return aMin;
182     }
183
184     virtual
185     vtkFloatingPointType
186     GetComponentMax(vtkIdType theCompID)
187     {
188       vtkFloatingPointType aMax = TMinMaxController::GetComponentMax(theCompID);
189       if ( !myMinMaxContainer.empty() ) {
190         TMinMaxContainer::const_iterator anIter = myMinMaxContainer.begin();
191         for(; anIter != myMinMaxContainer.end(); anIter++){
192           VISU::PMinMaxController aMinMaxController = anIter->second;
193           aMax = std::max(aMax, aMinMaxController->GetComponentMax(theCompID));
194         }
195       }
196       return aMax;
197     }
198   };
199
200   typedef SALOME::GenericObjPtr<TCompositeMinMaxController> PCompositeMinMaxController;
201 }
202
203 //------------------------------------------------------------------------
204 VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
205                                         VISU::View3D_ptr theView3D)
206 {
207   myStudy = theStudy;
208   myExecutionState = new VISU::ExecutionState(false);
209   myFrame = 0;
210   mySpeed = VISU::GetResourceMgr()->integerValue("VISU", "speed", 1);
211   myProportional = VISU::GetResourceMgr()->booleanValue("VISU", "use_proportional_timing", false);
212   myView = 0;
213
214   if (!CORBA::is_nil(theView3D)) {
215     VISU::View3D_i* pView = dynamic_cast<VISU::View3D_i*>(GetServant(theView3D).in());
216     SUIT_ViewWindow* aVW = pView->GetViewWindow();
217     setViewer( dynamic_cast<SVTK_ViewWindow*>(aVW) );
218   }
219
220   myAnimationMode = VISU::Animation::PARALLEL;
221   myTimeMinVal = 0;
222   myTimeMaxVal = 0;
223   myTimeMin = 0;
224   myTimeMax = 0;
225   myLastError = "";
226   myCycling = VISU::GetResourceMgr()->booleanValue("VISU", "cycled_animation", false);
227   myCleaningMemoryAtEachFrame = VISU::GetResourceMgr()->booleanValue("VISU", "clean_memory_at_each_frame", false);
228
229   myAnimEntry = "";
230
231   myDumpPath = new VISU::DumpPath( "" );
232
233   myAVIMaker = "jpeg2yuv";
234
235   myDumpMode = VISU::GetResourceMgr()->integerValue("VISU", "dump_mode", 0);
236   myTimeStampFrequency = VISU::GetResourceMgr()->integerValue("VISU", "time_stamp_frequency", 1);
237 }
238
239
240 //------------------------------------------------------------------------
241 VISU_TimeAnimation::~VISU_TimeAnimation()
242 {
243   if (QThread::isRunning() && !QThread::isFinished()) {
244     stopAnimation();
245     QThread::wait(500);
246     if (QThread::isRunning() && !QThread::isFinished()) {
247       QThread::terminate();
248     }
249   }
250
251   for (int i = 0; i < getNbFields() && myView; i++) {
252     clearData(myFieldsLst[i]);
253   }
254   clearFieldData();
255
256   delete myExecutionState;
257
258   delete myDumpPath;
259
260   /* Terminates the execution of the thread. 
261    * The thread may or may not be terminated immediately, 
262    * depending on the operating system's scheduling policies. 
263    *  
264    * Use QThread::wait() after terminate() for synchronous termination.
265    *
266    * When the thread is terminated, all threads waiting for the the thread to finish will be woken up.
267    * 
268    * Warning: This function is dangerous, and its use is discouraged. 
269    * The thread can be terminated at any point in its code path. 
270    * Threads can be terminated while modifying data. 
271    * There is no chance for the thread to cleanup after itself, 
272    * unlock any held mutexes, etc. In short, use this function only if absolutely necessary. 
273    */
274   //QThread::wait(100);
275   //QThread::terminate();
276   //QThread::wait(400);
277 }
278
279
280 //------------------------------------------------------------------------
281 void VISU_TimeAnimation::_connectView()
282 {
283   connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) );
284 }
285
286 //------------------------------------------------------------------------
287 bool VISU_TimeAnimation::addField (_PTR(SObject) theField)
288 {
289   if (!theField) return false;
290
291   FieldData aNewData;
292   aNewData.myField = theField;
293   aNewData.myNbFrames = 0;
294   aNewData.myPrsType = VISU::TSCALARMAP;
295   aNewData.myOffset[0] = aNewData.myOffset[1] = aNewData.myOffset[2] = 0;
296
297   // initialize myResult in aNewData
298   _PTR(SObject) aSObj = theField->GetFather();
299   aSObj = aSObj->GetFather();
300   aSObj = aSObj->GetFather();
301   CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj);
302   if (CORBA::is_nil(anObject)) return false;
303   aNewData.myResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
304
305   VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aNewData.myField);
306   if(VISU::Storable::FindValue(aMap,"myComment") != "FIELD")
307     return false;
308
309   aNewData.myNbTimes = VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
310
311   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
312     if ( aNewData.myNbTimes < 2 )
313       return false;
314     if ( !myFieldsLst.isEmpty() && myFieldsLst.first().myNbTimes != aNewData.myNbTimes )
315       return false;
316     if ( myFieldsLst.isEmpty() )
317       myFieldsAbsFrames.push_back(aNewData.myNbTimes);
318   }
319   else { // successive animation mode
320     if ( aNewData.myNbTimes < 1 )
321       return false;
322
323     long aNumCompCurr = VISU::Storable::FindValue(aMap, "myNumComponent").toLong();
324     if ( !myFieldsLst.isEmpty() ) {
325       VISU::Storable::TRestoringMap aFMap = VISU::Storable::GetStorableMap(myFieldsLst.first().myField);
326       long aNumComp = VISU::Storable::FindValue(aFMap, "myNumComponent").toLong();
327       if ( aNumCompCurr != aNumComp )
328         return false;
329     }
330
331     if ( !myFieldsLst.isEmpty() )
332       myFieldsAbsFrames.push_back(myFieldsAbsFrames.back() + aNewData.myNbTimes);
333     else
334       myFieldsAbsFrames.push_back(aNewData.myNbTimes);
335   }
336     
337   myFieldsLst.append(aNewData);
338   
339   //find Min/Max timestamps
340   _PTR(ChildIterator) anIter = myStudy->NewChildIterator(theField);
341   anIter->Next(); // First is reference on support
342   if ( myFieldsLst.size() == 1 ) { // the first field
343     myTimeMin = getTimeValue(anIter->Value());
344     myTimeMax = getTimeValue(anIter->Value());
345   }
346   for(; anIter->More(); anIter->Next()) {
347     if ( myTimeMin > getTimeValue(anIter->Value()) )
348       myTimeMin = getTimeValue(anIter->Value());
349     if ( myTimeMax < getTimeValue(anIter->Value()) )
350       myTimeMax = getTimeValue(anIter->Value());
351   }
352   
353   return true;
354 }
355
356 //------------------------------------------------------------------------
357 bool VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField)
358 {
359   SALOMEDS::SObject_var theFieldDup = SALOMEDS::SObject::_duplicate(theField);
360   _PTR(SObject) aField = VISU::GetClientSObject(theFieldDup, myStudy);
361   return addField(aField);
362 }
363
364
365 //------------------------------------------------------------------------
366 void VISU_TimeAnimation::_clearData(FieldData& theData) {
367   if (!myView) {
368     MESSAGE("Viewer is not defined for animation");
369     return;
370   }
371   theData.myTiming.clear();
372   vtkRenderer* aRen = myView->getRenderer();
373   if (!theData.myActors.empty()) {
374     for (int i = 0, iEnd = theData.myActors.size(); i < iEnd; i++) {
375       if (theData.myActors[i] != 0) {
376         theData.myActors[i]->RemoveFromRender(aRen);
377       }
378     }
379     theData.myActors.clear();
380   }
381   if (!theData.myPrs.empty()) {
382     for (int i = 0, iEnd = theData.myPrs.size(); i < iEnd; i++)
383       if (theData.myPrs[i] != 0) {
384         theData.myPrs[i]->_remove_ref();
385       }
386     theData.myPrs.clear();
387   }
388   theData.myNbFrames = 0;
389   myView->update();
390 }
391
392 //------------------------------------------------------------------------
393 void VISU_TimeAnimation::clearData(FieldData& theData) {
394   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,FieldData&>
395                    (this,&VISU_TimeAnimation::_clearData,theData));
396 }
397
398 namespace
399 {
400   //------------------------------------------------------------------------
401   template<class TPrs3d>
402   void
403   GeneratePresentations(_PTR(Study) theStudy,
404                         FieldData& theData,
405                         VISU::Result_i* theResult,
406                         bool theIsRangeDefined,
407                         CORBA::Double theTimeMin,
408                         CORBA::Double theTimeMax,
409                         QList<long> theSequence)
410   {
411     _PTR(ChildIterator) anIter = theStudy->NewChildIterator(theData.myField);
412     anIter->Next(); // First is reference on support
413
414     long aSequenceLength = theSequence.count();
415     bool isSequenceDefined = aSequenceLength > 0;
416     if (isSequenceDefined)
417       theData.myPrs.resize(aSequenceLength,NULL);
418
419     long aFrameId = 0;
420     long aSequenceIndex = 1;
421     for(; anIter->More(); anIter->Next(), aSequenceIndex++){
422       if (aFrameId == theData.myNbTimes) {
423         MESSAGE("There are extra timestamps in field");
424         return;
425       }
426       _PTR(SObject) aTimeStamp = anIter->Value();
427       if(!aTimeStamp) 
428         continue;
429
430       long aSequenceId = -1;
431
432       theData.myTiming[aFrameId] = VISU_TimeAnimation::getTimeValue(aTimeStamp);
433       if (theIsRangeDefined) {
434         if (theData.myTiming[aFrameId] < theTimeMin) 
435           continue;
436         if (theData.myTiming[aFrameId] > theTimeMax) 
437           break;
438       }
439       else if (isSequenceDefined) {
440         aSequenceId = theSequence.indexOf( aSequenceIndex );
441         if( aSequenceId == -1 )
442           continue;
443       }
444
445       VISU::Storable::TRestoringMap aTimeMap = VISU::Storable::GetStorableMap(aTimeStamp);
446       QString aMeshName = VISU::Storable::FindValue(aTimeMap,"myMeshName");
447       VISU::Entity anEntity = (VISU::Entity) VISU::Storable::FindValue(aTimeMap,"myEntityId").toInt();
448       QString aFieldName = VISU::Storable::FindValue(aTimeMap,"myFieldName");
449       int aTimeStampId = VISU::Storable::FindValue(aTimeMap,"myTimeStampId").toInt();
450       
451       bool anIsCreated = false;
452       TPrs3d* aPresent = new TPrs3d(VISU::ColoredPrs3d_i::EDoNotPublish);
453       aPresent->SetCResult(theResult);
454       aPresent->SetMeshName(aMeshName.toLatin1().data());
455       aPresent->SetEntity(anEntity);
456       aPresent->SetFieldName(aFieldName.toLatin1().data());
457       aPresent->SetTimeStampNumber(aTimeStampId);
458       try{       
459 #ifdef NO_CAS_CATCH
460         OCC_CATCH_SIGNALS;
461 #endif
462         if(aPresent->Apply(false)){
463           /*
464             if(isSequenceDefined)
465             {
466               theData.myPrs[aSequenceId] = aPresent;
467               aFrameId++;
468             }
469             else
470           */
471           theData.myPrs[aFrameId++] = aPresent;
472           anIsCreated = true;
473         }
474       }catch(Standard_Failure) {
475         Handle(Standard_Failure) aFail = Standard_Failure::Caught();
476         INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
477       }catch(std::exception& exc){
478         INFOS("Follow exception was occured :\n"<<exc.what());
479       }catch(...){
480         INFOS("Unknown exception was occured!");
481       }
482       if(!anIsCreated)
483         aPresent->_remove_ref();
484     }
485
486     theData.myNbFrames = aFrameId;
487
488     if (theData.myPrsType != VISU::TGAUSSPOINTS) {
489       for(long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++) {
490         if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(theData.myPrs[aFrameId])){
491           aPrs->SetOffset(theData.myOffset);
492         }
493       }
494     }
495   }
496 }
497
498 double getMinFieldsValue( QList<FieldData>& theFieldsLst )
499 {
500   // for successive animation mode only
501   double aRes;
502   for (int i = 0; i < theFieldsLst.count(); i++) {
503     if ( theFieldsLst[i].myPrs[0] ) {
504       aRes = theFieldsLst[i].myPrs[0]->GetMin();
505       break;
506     }
507   }
508
509   for (int i = 1; i < theFieldsLst.count() && theFieldsLst[i].myPrs[0]; i++) {
510     if ( aRes > theFieldsLst[i].myPrs[0]->GetMin() )
511       aRes = theFieldsLst[i].myPrs[0]->GetMin();    
512   }
513   return aRes;
514 }
515
516 double getMaxFieldsValue( QList<FieldData>& theFieldsLst )
517 {
518   // for successive animation mode only
519   double aRes;
520   for (int i = 0; i < theFieldsLst.count(); i++) {
521     if ( theFieldsLst[i].myPrs[0] ) {
522       aRes = theFieldsLst[i].myPrs[0]->GetMax();
523       break;
524     }
525   }
526
527   for (int i = 1; i < theFieldsLst.count() && theFieldsLst[i].myPrs[0]; i++) {
528     if ( aRes < theFieldsLst[i].myPrs[0]->GetMax() )
529       aRes = theFieldsLst[i].myPrs[0]->GetMax();    
530   }
531   return aRes;
532 }
533
534 void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum)
535 {
536   int nbf = myFieldsLst.size();
537   if( theFieldNum<0 || theFieldNum>nbf-1 )
538     return;
539
540   FieldData& aData = myFieldsLst[theFieldNum];
541
542   // Delete previous presentations
543   clearData(aData);
544
545   VISU::Result_i* aResult = createPresent(aData.myField);
546   VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aData.myField);
547   aData.myNbFrames = aData.myNbTimes;
548   //VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
549
550   aData.myPrs.resize(aData.myNbTimes,NULL);
551   aData.myTiming.resize(aData.myNbTimes);
552
553   QList<long> aSequence;
554   if( isSequenceDefined() )
555   {
556     bool ok = getIndicesFromSequence( mySequence, aSequence );
557     if( !ok )
558       return;
559   }
560
561   using namespace VISU;
562   switch (aData.myPrsType) {
563   case VISU::TSCALARMAP:
564     GeneratePresentations<ScalarMap_i>(myStudy,
565                                        aData,
566                                        aResult,
567                                        isRangeDefined(),
568                                        myTimeMinVal,
569                                        myTimeMaxVal,
570                                        aSequence);
571     break;
572   case VISU::TISOSURFACES: // Iso Surfaces
573     GeneratePresentations<IsoSurfaces_i>(myStudy,
574                                          aData,
575                                          aResult,
576                                          isRangeDefined(),
577                                          myTimeMinVal,
578                                          myTimeMaxVal,
579                                          aSequence);
580     break;
581   case VISU::TCUTPLANES: // Cut Planes
582     GeneratePresentations<CutPlanes_i>(myStudy,
583                                        aData,
584                                        aResult,
585                                        isRangeDefined(),
586                                        myTimeMinVal,
587                                        myTimeMaxVal,
588                                        aSequence);
589     break;
590   case VISU::TCUTLINES: // Cut Lines
591     GeneratePresentations<CutLines_i>(myStudy,
592                                       aData,
593                                       aResult,
594                                       isRangeDefined(),
595                                       myTimeMinVal,
596                                       myTimeMaxVal,
597                                       aSequence);
598     break;
599   case VISU::TCUTSEGMENT: // Cut Segment
600     GeneratePresentations<CutSegment_i>(myStudy,
601                                         aData,
602                                         aResult,
603                                         isRangeDefined(),
604                                         myTimeMinVal,
605                                         myTimeMaxVal,
606                                         aSequence);
607     break;
608   case VISU::TPLOT3D: // Plot3d
609     GeneratePresentations<Plot3D_i>(myStudy,
610                                     aData,
611                                     aResult,
612                                     isRangeDefined(),
613                                     myTimeMinVal,
614                                     myTimeMaxVal,
615                                     aSequence);
616     break;
617   case VISU::TDEFORMEDSHAPE: // Deformed Shape
618     GeneratePresentations<DeformedShape_i>(myStudy,
619                                            aData,
620                                            aResult,
621                                            isRangeDefined(),
622                                            myTimeMinVal,
623                                            myTimeMaxVal,
624                                            aSequence);
625     break;
626   case VISU::TVECTORS: // Vectors
627     GeneratePresentations<Vectors_i>(myStudy,
628                                      aData,
629                                      aResult,
630                                      isRangeDefined(),
631                                      myTimeMinVal,
632                                      myTimeMaxVal,
633                                      aSequence);
634     break;
635   case VISU::TSTREAMLINES: // Stream Lines
636     GeneratePresentations<StreamLines_i>(myStudy,
637                                          aData,
638                                          aResult,
639                                          isRangeDefined(),
640                                          myTimeMinVal,
641                                          myTimeMaxVal,
642                                          aSequence);
643     break;
644   case VISU::TGAUSSPOINTS: // Gauss Points
645     GeneratePresentations<GaussPoints_i>(myStudy,
646                                          aData,
647                                          aResult,
648                                          isRangeDefined(),
649                                          myTimeMinVal,
650                                          myTimeMaxVal,
651                                          aSequence);
652     break;
653   case VISU::TSCALARMAPONDEFORMEDSHAPE: // Scalar map on deformed shape
654   case VISU::TDEFORMEDSHAPEANDSCALARMAP:
655     GeneratePresentations<DeformedShapeAndScalarMap_i>(myStudy,
656                                                        aData,
657                                                        aResult,
658                                                        isRangeDefined(),
659                                                        myTimeMinVal,
660                                                        myTimeMaxVal,
661                                                        aSequence);
662     break;
663   default:
664     MESSAGE("Not implemented for this presentation type: " << aData.myPrsType);
665     return;
666   }
667   
668   if ( myAnimationMode == VISU::Animation::SUCCESSIVE ) { // successive animation mode
669     if ( myFieldsAbsFrames.size() == getNbFields() ) 
670       myFieldsAbsFrames.clear();
671     if ( theFieldNum > 0 )
672       myFieldsAbsFrames.push_back(myFieldsAbsFrames.back() + aData.myNbFrames);      
673     else
674       myFieldsAbsFrames.push_back(aData.myNbFrames);
675
676     if (theFieldNum == getNbFields() - 1) {
677       if ( aData.myPrsType != VISU::TGAUSSPOINTS && aData.myPrsType != TDEFORMEDSHAPEANDSCALARMAP && aData.myPrsType != TSCALARMAPONDEFORMEDSHAPE) {
678
679         // Initialize the MinMax controller
680         VISU::PCompositeMinMaxController aMinMaxController(new VISU::TCompositeMinMaxController());
681         if ( myAnimationMode == VISU::Animation::PARALLEL ) {
682           FieldData& aFieldData = getFieldData(theFieldNum);
683           VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[0];
684           aMinMaxController->AddController( aPrs3d, VISU::CreateDefaultMinMaxController( aPrs3d ) );
685         } else {
686           for (int aFieldId = 0; aFieldId < getNbFields(); aFieldId++) {
687             FieldData& aFieldData = getFieldData(aFieldId);
688             VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[0];
689             aMinMaxController->AddController( aPrs3d, VISU::CreateDefaultMinMaxController( aPrs3d ) );
690           }
691         }
692
693         double aMin = getMinFieldsValue(myFieldsLst);
694         double aMax = getMaxFieldsValue(myFieldsLst);
695
696         for (int aFieldId = 0; aFieldId < getNbFields(); aFieldId++) {
697           FieldData& aFieldData = getFieldData(aFieldId);
698           for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) {
699             VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[aFrameId];
700             aPrs3d->SetMinMaxController(aMinMaxController);
701             if (VISU::IsoSurfaces_i* anIsoSurfaces = dynamic_cast<VISU::IsoSurfaces_i*>(aPrs3d))
702               anIsoSurfaces->SetSubRange(aMin, aMax);
703           }
704         }
705       }
706     }
707   }
708 }
709
710
711 //------------------------------------------------------------------------
712 CORBA::Boolean VISU_TimeAnimation::_generateFrames() {
713   if (!myView) {
714     MESSAGE("Viewer is not defined for animation");
715     return false;
716   }
717
718   myLastError = QString("Frame(s) for ");
719   bool aNoError = true;
720
721   clearView();
722
723   for (int i = 0; i < getNbFields(); i++) {
724     FieldData& aData = myFieldsLst[i];
725     aData.myActors.resize(aData.myNbFrames,NULL);
726     for (long j = 0; j < aData.myNbFrames; j++) {
727       VISU_Actor* aActor = NULL;
728       try{
729         aData.myPrs[j]->SetOffset(aData.myOffset);
730         aActor = aData.myPrs[j]->CreateActor();
731         myView->AddActor(aActor);
732         bool condition = ( myAnimationMode == VISU::Animation::PARALLEL ) ? (j == 0) : (j == 0 && i == 0);
733         if(condition)
734           aActor->VisibilityOn();
735         else
736           aActor->VisibilityOff();
737       }catch(...){ //catch(std::runtime_error& exc){
738         aNoError = false;
739         myLastError += QString("%1 ").arg(aData.myTiming[j]);
740       }
741       aData.myActors[j] = aActor;
742     }
743   }
744   myFrame = 0;
745   myLastError += QString(" timestamp(s) cannot be created.");
746   ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
747                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
748   myView->Repaint();
749   return aNoError;
750 }
751
752 //------------------------------------------------------------------------
753 CORBA::Boolean VISU_TimeAnimation::generateFrames()
754 {
755   return ProcessEvent(new TMemFunEvent<VISU_TimeAnimation,bool>
756                       (this,&VISU_TimeAnimation::_generateFrames));
757 }
758
759 //------------------------------------------------------------------------
760 void VISU_TimeAnimation::_clearView() {
761   if (!myView) {
762     MESSAGE("Viewer is not defined for animation");
763     return;
764   }
765   vtkRenderer* aRen = myView->getRenderer();
766   for (int i = 0; i < getNbFields(); i++) {
767     FieldData& aData = myFieldsLst[i];
768     if (!aData.myActors.empty()) {
769       for (int i = 0, iEnd = aData.myActors.size(); i < iEnd; i++) {
770         if (aData.myActors[i] != 0) {
771           aData.myActors[i]->RemoveFromRender(aRen);
772         }
773       }
774       aData.myActors.clear();
775     }
776   }
777   VISU::RepaintView(myView);
778 }
779
780 //------------------------------------------------------------------------
781 void VISU_TimeAnimation::clearView()
782 {
783   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
784                    (this,&VISU_TimeAnimation::_clearView));
785 }
786
787 //------------------------------------------------------------------------
788 void VISU_TimeAnimation::_visibilityOff(int num_field, int num_frame) {
789   if (!myView) {
790     MESSAGE("Viewer is not defined for animation");
791     return;
792   }
793   if ( num_field < 0 || num_frame < 0 ) return;
794   FieldData& aData = myFieldsLst[num_field];
795   if ( aData.myActors.empty() ) return;
796   VISU_Actor* aActor = aData.myActors[num_frame];
797   if (! myCleaningMemoryAtEachFrame) {
798     //
799     // Usual behaviour : VisibilityOff()
800     // Problem : It don't clean the memory so if there is
801     //           a lot of frames, the memory grows dramatically
802     //
803     aActor->VisibilityOff();
804   } else {
805     //
806     // myCleaningMemoryAtEachFrame behaviour:
807     // Delete the actor and re-creation it with VisibilityOff()
808     // since it takes memory only at VisibilityOn()
809     //
810     // Delete the actor
811     aActor->RemoveFromRender(myView->getRenderer());
812     // Re-create the actor
813     aActor = aData.myPrs[num_frame]->CreateActor();
814     myView->AddActor(aActor);
815     aActor->VisibilityOff();
816     aData.myActors[num_frame] = aActor;
817   }
818 }
819
820 //------------------------------------------------------------------------
821 void VISU_TimeAnimation::visibilityOff(int num_field, int num_frame)
822 {
823   ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,int,int>
824                    (this,&VISU_TimeAnimation::_visibilityOff,num_field,num_frame));
825 }
826
827 //------------------------------------------------------------------------
828 void VISU_TimeAnimation::stopAnimation()
829 {
830   myExecutionState->SetActive(false);
831 }
832
833 //------------------------------------------------------------------------
834 void VISU_TimeAnimation::_startAnimation() {
835   if (!myExecutionState->IsActive()) {
836     myExecutionState->SetActive(true);
837     QThread::start();
838   }
839 }
840
841 //------------------------------------------------------------------------
842 void VISU_TimeAnimation::startAnimation()
843 {
844   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
845                    (this,&VISU_TimeAnimation::_startAnimation));
846 }
847
848 //------------------------------------------------------------------------
849 void VISU_TimeAnimation::_nextFrame() {
850   if (!myView) {
851     MESSAGE("Viewer is not defined for animation");
852     return;
853   }
854   stopAnimation();
855   if (myFrame < getNbFrames() - 1 ) { //(myFieldsLst[0].myNbFrames-1)) {
856     int i;
857     std::pair<int,long> aPair;
858     int aFieldId;
859     long aFrameId;
860
861     if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
862       for (i = 0; i < getNbFields(); i++)
863         if (myFieldsLst[i].myActors[myFrame] != 0)
864           visibilityOff(i, myFrame);
865     }
866     else { //successive animation mode
867       aPair = getRelativeFrameNumber(myFrame);
868       aFieldId = aPair.first;
869       aFrameId = aPair.second;
870       if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
871         visibilityOff(aFieldId, aFrameId);
872     }
873
874     myFrame++;
875
876     if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
877       for (i = 0; i < getNbFields(); i++)
878         if (myFieldsLst[i].myActors[myFrame] != 0)
879           myFieldsLst[i].myActors[myFrame]->VisibilityOn();
880
881       ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
882                                                                                 myFrame, myFieldsLst[0].myTiming[myFrame]));
883     }
884     else { //successive animation mode
885       aPair = getRelativeFrameNumber(myFrame);
886       aFieldId = aPair.first;
887       aFrameId = aPair.second;
888       if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
889         myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
890
891       ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
892                                                                                 myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
893     }
894     myView->Repaint();
895   }
896 }
897
898 //------------------------------------------------------------------------
899 void VISU_TimeAnimation::nextFrame()
900 {
901   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
902                    (this,&VISU_TimeAnimation::_nextFrame));
903 }
904
905 //------------------------------------------------------------------------
906 void VISU_TimeAnimation::_prevFrame() {
907   if (!myView) {
908     MESSAGE("Viewer is not defined for animation");
909     return;
910   }
911   stopAnimation();
912   if (myFrame > 0) {
913     int i;
914     std::pair<int,long> aPair;
915     int aFieldId;
916     long aFrameId;
917
918     if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
919       for (i = 0; i < getNbFields(); i++)
920         if (myFieldsLst[i].myActors[myFrame] != 0)
921           visibilityOff(i, myFrame);
922     }
923     else { //successive animation mode
924       aPair = getRelativeFrameNumber(myFrame);
925       aFieldId = aPair.first;
926       aFrameId = aPair.second;
927       if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
928           visibilityOff(aFieldId, aFrameId);
929     }
930
931     myFrame--;
932
933     if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
934       for (i = 0; i < getNbFields(); i++)
935         if (myFieldsLst[i].myActors[myFrame] != 0)
936           myFieldsLst[i].myActors[myFrame]->VisibilityOn();
937
938       ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
939                                                                                 myFrame, myFieldsLst[0].myTiming[myFrame]));
940     }
941     else { //successive animation mode
942       aPair = getRelativeFrameNumber(myFrame);
943       aFieldId = aPair.first;
944       aFrameId = aPair.second;
945       if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
946           myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
947
948       ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
949                                                                                 myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
950     }
951     myView->Repaint();
952   }
953 }
954
955 //------------------------------------------------------------------------
956 void VISU_TimeAnimation::prevFrame()
957 {
958   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
959                    (this,&VISU_TimeAnimation::_prevFrame));
960 }
961
962 //------------------------------------------------------------------------
963 void VISU_TimeAnimation::_firstFrame() {
964   if (!myView) {
965     MESSAGE("Viewer is not defined for animation");
966     return;
967   }
968   stopAnimation();
969   int i;
970   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
971     for (i = 0; i < getNbFields(); i++)
972       if(!myFieldsLst[i].myActors.empty())
973         if (myFieldsLst[i].myActors[myFrame] != 0)
974           visibilityOff(i, myFrame);
975     }
976   else { //successive animation mode
977     std::pair<int,long> aPair = getRelativeFrameNumber(myFrame);
978     int aFieldId = aPair.first;
979     long aFrameId = aPair.second;
980     if(!myFieldsLst[aFieldId].myActors.empty())
981       if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
982         visibilityOff(aFieldId, aFrameId);
983   }
984   myFrame = 0;
985
986   int imax;
987   if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode 
988     imax = getNbFields();
989   else //successive animation mode
990     imax = 1;
991
992   for (i = 0; i < imax; i++)
993     if(!myFieldsLst[i].myActors.empty())
994       if (myFieldsLst[i].myActors[myFrame] != 0)
995         myFieldsLst[i].myActors[myFrame]->VisibilityOn();
996
997   if(!myFieldsLst[0].myTiming.empty()){
998     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
999                                                                               myFrame, myFieldsLst[0].myTiming[myFrame]));
1000     myView->Repaint();
1001   }
1002 }
1003
1004 //------------------------------------------------------------------------
1005 void VISU_TimeAnimation::firstFrame()
1006 {
1007   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
1008                    (this,&VISU_TimeAnimation::_firstFrame));
1009 }
1010
1011 //------------------------------------------------------------------------
1012 void VISU_TimeAnimation::_lastFrame() {
1013   if (!myView) {
1014     MESSAGE("Viewer is not defined for animation");
1015     return;
1016   }
1017   stopAnimation();
1018   int i;
1019   std::pair<int,long> aPair;
1020   int aFieldId;
1021   long aFrameId;
1022
1023   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1024     for (i = 0; i < getNbFields(); i++)
1025       if (myFieldsLst[i].myActors[myFrame] != 0)
1026         visibilityOff(i, myFrame);
1027   }
1028   else { //successive animation mode
1029     aPair = getRelativeFrameNumber(myFrame);
1030     aFieldId = aPair.first;
1031     aFrameId = aPair.second;
1032     if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
1033       visibilityOff(aFieldId, aFrameId);
1034   }
1035
1036   myFrame = getNbFrames() - 1; //myFieldsLst[0].myNbFrames-1;
1037
1038   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1039     for (i = 0; i < getNbFields(); i++)
1040       if (myFieldsLst[i].myActors[myFrame] != 0)
1041         myFieldsLst[i].myActors[myFrame]->VisibilityOn();
1042     
1043     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
1044                                                                               myFrame, myFieldsLst[0].myTiming[myFrame]));
1045   }
1046   else { //successive animation mode
1047     aPair = getRelativeFrameNumber(myFrame);
1048     aFieldId = aPair.first;
1049     aFrameId = aPair.second;
1050     if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
1051         myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
1052
1053     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
1054                                                                               myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
1055   }
1056
1057   myView->Repaint();
1058 }
1059
1060 //------------------------------------------------------------------------
1061 void VISU_TimeAnimation::lastFrame()
1062 {
1063   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
1064                    (this,&VISU_TimeAnimation::_lastFrame));
1065 }
1066
1067
1068 //------------------------------------------------------------------------
1069 // For Batchmode using
1070 void VISU_TimeAnimation::_gotoFrame(CORBA::Long theFrame) {
1071   if (!myView) {
1072     MESSAGE("Viewer is not defined for animation");
1073     return;
1074   }
1075   if ((theFrame < 0) || (theFrame > (getNbFrames()-1)))
1076     return;
1077   stopAnimation();
1078   int i;
1079   std::pair<int,long> aPair;
1080   int aFieldId;
1081   long aFrameId;
1082   
1083   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1084     for (i = 0; i < getNbFields(); i++)
1085       if (myFieldsLst[i].myActors[myFrame] != 0)
1086         visibilityOff(i, myFrame);
1087   }
1088   else { //successive animation mode
1089     aPair = getRelativeFrameNumber(myFrame);
1090     aFieldId = aPair.first;
1091     aFrameId = aPair.second;
1092     if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
1093         visibilityOff(aFieldId, aFrameId);
1094   }
1095
1096   myFrame = theFrame;
1097
1098   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1099     for (i = 0; i < getNbFields(); i++)
1100       if (myFieldsLst[i].myActors[myFrame] != 0)
1101         myFieldsLst[i].myActors[myFrame]->VisibilityOn();
1102
1103     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
1104                                                                               myFrame, myFieldsLst[0].myTiming[myFrame]));
1105   }
1106   else { //successive animation mode
1107     aPair = getRelativeFrameNumber(myFrame);
1108     aFieldId = aPair.first;
1109     aFrameId = aPair.second;
1110     if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
1111         myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
1112
1113     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
1114                                                                               myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
1115   }
1116
1117   myView->Repaint();
1118 }
1119
1120 //------------------------------------------------------------------------
1121 void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame)
1122 {
1123   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,CORBA::Long>
1124                    (this,&VISU_TimeAnimation::_gotoFrame,theFrame));
1125 }
1126
1127 //------------------------------------------------------------------------
1128 void VISU_TimeAnimation::_emitFrameChanged(long theNewFrame, double theTime)
1129 {
1130   emit frameChanged(theNewFrame, theTime);
1131 }
1132
1133 //------------------------------------------------------------------------
1134 void VISU_TimeAnimation::_emitStopped()
1135 {
1136   emit stopped();
1137 }
1138
1139 //------------------------------------------------------------------------
1140 VISU::ColoredPrs3d_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CORBA::Long theFrame) {
1141   if ((theField > getNbFields()) || (theField < 0))
1142     return VISU::ColoredPrs3d::_nil();
1143   if ((theFrame < 0) || (theFrame > (myFieldsLst[theField].myNbFrames - 1)))
1144     return VISU::ColoredPrs3d::_nil();
1145   return myFieldsLst[theField].myPrs[theFrame]->_this();
1146 }
1147
1148 //------------------------------------------------------------------------
1149 void VISU_TimeAnimation::setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType) {
1150   if ( theFieldNum < 0 || theFieldNum >= myFieldsLst.size() )
1151     return;
1152
1153   myFieldsLst[theFieldNum].myPrsType = theType;
1154 }
1155
1156 //------------------------------------------------------------------------
1157 VISU::VISUType VISU_TimeAnimation::getPresentationType(CORBA::Long theFieldNum) {
1158   if ( theFieldNum < 0 || theFieldNum >= myFieldsLst.size() )
1159     return VISU::TNONE;
1160   
1161   return myFieldsLst[theFieldNum].myPrsType;
1162 }
1163
1164 //------------------------------------------------------------------------
1165 CORBA::Long VISU_TimeAnimation::getNbFrames() {
1166   if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode
1167     return (getNbFields() > 0)? myFieldsLst[0].myNbFrames : 0;
1168   else //successive animation mode
1169     return (getNbFields() > 0 && !myFieldsAbsFrames.empty()) ? myFieldsAbsFrames[myFieldsAbsFrames.size()-1] : 0;
1170 }
1171
1172 //------------------------------------------------------------------------
1173 long VISU_TimeAnimation::getAbsoluteFrameNumber(std::pair<int,long> theFieldTimeStamp)
1174 {
1175   long aRes = -1;
1176   if ( getNbFields() > 0 ) {
1177     int aFieldId = theFieldTimeStamp.first;
1178     long aFrameNum = theFieldTimeStamp.second + 1;
1179     if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1180       if ( aFrameNum <= myFieldsAbsFrames[0] )
1181         aRes = aFrameNum;
1182     }
1183     else { //successive animation mode
1184       if ( aFieldId == 0 && aFrameNum <= myFieldsAbsFrames[aFieldId] )
1185         aRes = aFrameNum;
1186       else if ( aFieldId && aFrameNum <= myFieldsAbsFrames[aFieldId] - myFieldsAbsFrames[aFieldId-1] )
1187         aRes = myFieldsAbsFrames[aFieldId-1] + aFrameNum;
1188     }
1189   }
1190   return aRes - 1;
1191 }
1192
1193 //------------------------------------------------------------------------
1194 std::pair<int,long> VISU_TimeAnimation::getRelativeFrameNumber(long theFrame)
1195 {
1196   std::pair<int,long> aRes;
1197   if ( getNbFields() > 0 && theFrame < getNbFrames() ) {
1198     theFrame = theFrame + 1;
1199     if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
1200       aRes.first = 0;
1201       aRes.second = theFrame - 1;
1202     }
1203     else { //successive animation mode
1204       for (int i = 0, iEnd = myFieldsAbsFrames.size(); i < iEnd; i++)
1205         if ( myFieldsAbsFrames[i] >= theFrame ) {
1206           aRes.first = i;
1207           if ( i == 0 )
1208             aRes.second = theFrame - 1;
1209           else
1210             aRes.second = theFrame-myFieldsAbsFrames[i-1] - 1;
1211           break;
1212         }
1213     }
1214   }
1215   return aRes;
1216 }
1217
1218 //------------------------------------------------------------------------
1219 void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QList<int>& theIndexList )
1220 {
1221   double k = 1;
1222   double aOneVal = 1;
1223   FieldData& aFirstFieldData = myFieldsLst[0];
1224   if (aFirstFieldData.myNbFrames > 2)
1225     aOneVal = ( myTimeMax - myTimeMin ) / getNbFrames();
1226   int aNbFiles = 0;
1227
1228   bool aHasNextFrame = aFirstFieldData.myField && aFirstFieldData.myNbFrames > 0;
1229   while (aHasNextFrame && myExecutionState->IsActive()) {
1230     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>
1231                      (this, &VISU_TimeAnimation::_emitFrameChanged,
1232                       myFrame, aFirstFieldData.myTiming[myFrame]));
1233     if (myExecutionState->IsActive()) {
1234       for (int i = 0; i < getNbFields(); i++) {
1235         FieldData& aData = myFieldsLst[i];
1236         if (aData.myNbFrames == 0)
1237           continue;
1238         if (myFrame > 0) {
1239           if (aData.myActors[myFrame-1] != 0)
1240             visibilityOff(i, myFrame-1);
1241         } else {
1242           if (aData.myActors[aData.myNbFrames-1] != 0)
1243             visibilityOff(i, aData.myNbFrames-1);
1244         }
1245         if (aData.myActors[myFrame] != 0 && myView) {
1246           ProcessVoidEvent(new TVoidMemFunEvent<VISU_Actor>(aData.myActors[myFrame],
1247                                                             &VISU_Actor::VisibilityOn));
1248         }
1249       }
1250       if (!myView)
1251         return;
1252       bool repainArg = false;
1253       ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
1254                                                                       &SVTK_ViewWindow::Repaint,
1255                                                                       repainArg));
1256     }
1257
1258     k = 1;
1259     if (myProportional) {
1260       switch (myFrame) {
1261       case 0:
1262         break;
1263       case 1:
1264         if (aFirstFieldData.myNbFrames > 2)
1265           k = (aFirstFieldData.myTiming[myFrame+1] -
1266                aFirstFieldData.myTiming[myFrame]) / aOneVal;
1267         break;
1268       default:
1269         if (myFrame < (aFirstFieldData.myNbFrames - 1))
1270           k = (aFirstFieldData.myTiming[myFrame+1] -
1271                aFirstFieldData.myTiming[myFrame]) / aOneVal;
1272       }
1273     }
1274     int delay = (int)(1000. * k / mySpeed);
1275     theIsDumping = !myDumpPath->GetPath().isEmpty();
1276     if (delay < 1 && theIsDumping) {
1277       // We must unlock mutex for some time before grabbing to allow view updating
1278       delay = 1;
1279     }
1280     msleep(delay);
1281     if (!myExecutionState->IsActive()) 
1282       return;
1283
1284     if (theIsDumping) {
1285       // We must unlock mutex for some time before grabbing to allow view updating
1286       msleep(delay);
1287       if (!myExecutionState->IsActive()) 
1288         return;
1289
1290       if (!(aFirstFieldData.myField)) // break, if field was deleted.
1291         break;
1292
1293       saveImages( 0, aOneVal, aNbFiles, theIndexList );
1294     }
1295
1296     if (!myExecutionState->IsActive()) 
1297       break;
1298
1299     myFrame++;
1300     if (myFrame == aFirstFieldData.myNbFrames) {
1301       if (!myCycling) {
1302         aHasNextFrame = false;
1303         myFrame--;
1304       }
1305       else
1306         myFrame = 0;
1307     }
1308   } // while (aHasNextFrame && myExecutionState->IsActive())
1309 }
1310
1311 //------------------------------------------------------------------------
1312 void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QList<int>& theIndexList )
1313 {
1314   if (myFrame >= getNbFrames() - 1)
1315   {
1316     myExecutionState->SetActive(false);
1317     return;
1318   }
1319
1320   double k = 1;
1321   double aOneVal = 1;
1322   FieldData& aFirstFieldData = myFieldsLst[0];
1323   if (aFirstFieldData.myNbFrames > 2)
1324     aOneVal = ( myTimeMax - myTimeMin ) / getNbFrames();
1325   int aNbFiles = 0;
1326   long aFrame = myFrame;
1327
1328   bool aHasNextFrame = true;
1329   while (aHasNextFrame && myExecutionState->IsActive())
1330   {
1331     for (int aFieldId = 0;
1332          (aFieldId < getNbFields()) && (myFieldsLst[aFieldId].myField);
1333          aFieldId++, aFrame = 0)
1334     {
1335       if (!myExecutionState->IsActive()) break;
1336
1337       FieldData& aData = myFieldsLst[aFieldId];
1338       if ( !aData.myPrs[0] ) continue;
1339       for (; aFrame < aData.myNbFrames && myExecutionState->IsActive(); aFrame++, myFrame++)
1340       {
1341         ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>
1342                          (this, &VISU_TimeAnimation::_emitFrameChanged,
1343                           myFrame, myFieldsLst[aFieldId].myTiming[aFrame]));
1344
1345         if (myExecutionState->IsActive()) {
1346           if (aFrame > 0) {
1347             if (aData.myActors[aFrame-1] != 0)
1348               visibilityOff(aFieldId, aFrame-1);
1349           } else if ( myFrame > 0) {
1350             if (myFieldsLst[aFieldId-1].myActors[myFieldsLst[aFieldId-1].myNbFrames-1] != 0)
1351               visibilityOff(aFieldId-1, myFieldsLst[aFieldId-1].myNbFrames-1);
1352           } else if ( myCycling ) {
1353             if (myFieldsLst[getNbFields()-1].myActors[myFieldsLst[getNbFields()-1].myNbFrames-1] != 0)
1354               visibilityOff(getNbFields()-1, myFieldsLst[getNbFields()-1].myNbFrames-1);
1355           } else {
1356             if (aData.myActors[aData.myNbFrames-1] != 0)
1357               visibilityOff(aFieldId, aData.myNbFrames-1);
1358           }
1359           if (aData.myActors[aFrame] != 0 && myView) {
1360             ProcessVoidEvent(new TVoidMemFunEvent<VISU_Actor>(aData.myActors[aFrame],
1361                                                               &VISU_Actor::VisibilityOn));
1362           }
1363
1364           if (!myView)
1365             return;
1366           bool repainArg = false;
1367           ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
1368                                                                           &SVTK_ViewWindow::Repaint,
1369                                                                           repainArg));
1370         }
1371
1372         k = 1;
1373         if (myProportional) {
1374           switch (aFrame) {
1375           case 0:
1376             break;
1377           case 1:
1378             if (aFirstFieldData.myNbFrames > 2)
1379               k = (aFirstFieldData.myTiming[aFrame+1] -
1380                    aFirstFieldData.myTiming[aFrame]) / aOneVal;
1381             break;
1382           default:
1383             if (aFrame < (aFirstFieldData.myNbFrames - 1))
1384               k = (aFirstFieldData.myTiming[aFrame+1] -
1385                    aFirstFieldData.myTiming[aFrame]) / aOneVal;
1386           }
1387         }
1388         int delay = (int)(1000. * k / mySpeed);
1389         theIsDumping = !myDumpPath->GetPath().isEmpty();
1390         if (delay < 1 && theIsDumping) {
1391           // We must unlock mutex for some time before grabbing to allow view updating
1392           delay = 1;
1393         }
1394         msleep(delay);
1395
1396         if (!myExecutionState->IsActive()) return;
1397
1398         if (theIsDumping) {
1399           // We must unlock mutex for some time before grabbing to allow view updating
1400           msleep(delay);
1401           if (!myExecutionState->IsActive()) return;
1402
1403           if (!(myFieldsLst[aFieldId].myField)) // break, if field was deleted.
1404             break;
1405
1406           saveImages( aFieldId, aOneVal, aNbFiles, theIndexList );
1407         }
1408       } // for (; aFrame < aData.myNbFrames && myExecutionState->IsActive(); aFrame++, myFrame++)
1409     } // for (int aFieldId = 0;
1410
1411     if (!myCycling) {
1412       aHasNextFrame = false;
1413       myFrame--;
1414     }
1415     else {
1416       myFrame = 0;
1417       aFrame = myFrame;
1418     }
1419   } // while (aHasNextFrame && myExecutionState->IsActive())
1420 }
1421
1422 //------------------------------------------------------------------------
1423 void VISU_TimeAnimation::saveImages( int theFieldId, 
1424                                      double& theOneVal, int& theNbFiles, 
1425                                      QList<int>& theIndexList )
1426 {
1427   if (myDumpFormat.compare("AVI") != 0) {
1428     QString aFile(myDumpPath->GetPath());
1429
1430     int aFrameNb = myFrame; // parallel animation mode
1431     if ( myAnimationMode == VISU::Animation::SUCCESSIVE ) // successive animation mode
1432       aFrameNb = getRelativeFrameNumber(myFrame).second;
1433
1434     int aMaxNb = myFieldsLst[theFieldId].myTiming.size();
1435     int nbDigits = QString("%1").arg(aMaxNb).length();
1436     QString aFormat = QString("%.%1d_").arg(nbDigits);
1437
1438     QString aName;
1439     aName.sprintf(aFormat.toLatin1().data(), aFrameNb);
1440     aName += QString("%1").arg(myFieldsLst[theFieldId].myTiming[aFrameNb]);
1441
1442     int aPos = -1;
1443     while ((aPos = aName.indexOf(".")) > -1 )
1444       aName.replace(aPos, 1, "_");
1445     aFile += aName;
1446     aFile += ".";
1447     aFile += myDumpFormat.toLower();
1448     ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>
1449                      (myView,&SVTK_ViewWindow::RefreshDumpImage)); // IPAL13602
1450     ProcessEvent(new TMemFun2ArgEvent<SUIT_ViewWindow,bool,const QString&,const QString&>
1451                  (myView,&SUIT_ViewWindow::dumpViewToFormat,aFile,myDumpFormat));
1452   } else {
1453     QFileInfo aFileInfo(myDumpPath->GetPath());
1454     QString aDirPath = aFileInfo.absolutePath();
1455     QString aBaseName = aFileInfo.fileName();
1456     
1457     if( myTimeStampFrequency > 1 && myFrame % myTimeStampFrequency != 0 )
1458       return;
1459
1460     switch (myFrame) {
1461     case 0: 
1462       break;
1463     case 1:
1464       myFileIndex += 5;
1465       break;
1466     default:
1467       if (myProportional) {
1468         FieldData& aFirstFieldData = myFieldsLst[0];
1469         double p = (aFirstFieldData.myTiming[myFrame] -
1470                     aFirstFieldData.myTiming[myFrame-1]) / theOneVal;
1471         myFileIndex += (long) (5*p);
1472       } else {
1473         myFileIndex += 5;
1474       }
1475     }
1476     
1477     QString aFile = aDirPath + QDir::separator() + aBaseName;
1478     aFile += "_";
1479     aFile += QString("%1").arg(myFileIndex).rightJustified(8, '0');
1480     aFile += ".jpeg";
1481     
1482     /* check image size is divisable 16
1483        myView->dumpViewToFormat(aFile,"JPEG");
1484     */
1485     SUIT_ViewWindow* aView = myView;
1486     ProcessVoidEvent(new TVoidMemFunEvent<SVTK_ViewWindow>(myView,&SVTK_ViewWindow::RefreshDumpImage)); // IPAL13602
1487     QImage img = ProcessEvent(new TMemFunEvent<SUIT_ViewWindow,QImage>(aView,&SUIT_ViewWindow::dumpView));
1488     if (!img.isNull()) {
1489       int width = img.width(); width = (width/16)*16;
1490       int height = img.height(); height = (height/16)*16;
1491       QImage copy = img.copy(0, 0, width, height);
1492       if (copy.save(aFile, "JPEG")) {
1493         theIndexList.append(myFileIndex);
1494         theNbFiles++;
1495       }
1496     }
1497   }
1498 }
1499
1500 //------------------------------------------------------------------------
1501 void VISU_TimeAnimation::run()
1502 {
1503   if (!myView) {
1504     MESSAGE("Viewer is not defined for animation");
1505     return;
1506   }
1507
1508   bool isDumping = !myDumpPath->GetPath().isEmpty();
1509   myFileIndex = 0;
1510   QList<int> anIndexList;
1511
1512   if ( myAnimationMode == VISU::Animation::PARALLEL ) // parallel animation mode
1513     parallelAnimation( isDumping, anIndexList );
1514   else //successive animation mode
1515     successiveAnimation( isDumping, anIndexList );
1516
1517   // make AVI file if need
1518   if (isDumping && myDumpFormat.compare("AVI") == 0 && myExecutionState->IsActive()) {
1519     double aFPS = 17.3 * mySpeed / myTimeStampFrequency;
1520
1521     QFileInfo aFileInfo(myDumpPath->GetPath());
1522     QString aDirPath = aFileInfo.absolutePath();
1523     QString aBaseName = aFileInfo.fileName();
1524
1525     // add missing files
1526     if (anIndexList.count() > 1) {
1527       QString aFFile = aDirPath + "/" + aBaseName;
1528       aFFile += QString("_%1.jpeg");
1529       int aStartIndex = anIndexList[0], anEndIndex;
1530       for (int i = 1; i < anIndexList.count(); i++) {
1531         anEndIndex = anIndexList[i];
1532         QString aCurFile = aFFile.arg(QString::number(aStartIndex).rightJustified(8, '0'));
1533         QStringList aCommands;
1534         QString aSeparator;
1535         for (int j = aStartIndex+1; j < anEndIndex; j++) {
1536           QString aFile = aFFile.arg(QString::number(j).rightJustified(8, '0'));
1537 #ifndef WIN32
1538           aCommands.append(QString("ln -s %1 %2").arg(aCurFile).arg(aFile));
1539           aSeparator = QString(" ; \\\n");
1540 #else
1541           aCommands.append(QString("COPY /Y %1 %2 > NUL").arg(QString(aCurFile).replace("/","\\\\")).arg(QString(aFile).replace("/","\\\\")));
1542           aSeparator = QString(" & ");
1543 #endif
1544         }
1545         system(aCommands.join(aSeparator).toLatin1().data());
1546         aStartIndex = anEndIndex;
1547       }
1548     }
1549
1550     // make AVI file
1551     QString aPattern = aDirPath + "/" + aBaseName;
1552     aPattern += "_\%08d.jpeg";
1553
1554     QString aCmd = myAVIMaker;
1555     aCmd += " -I p";
1556     aCmd += " -v 0";
1557     aCmd += QString(" -f %1").arg(aFPS);
1558     // aCmd += QString(" -n %1").arg(aNbFiles);
1559     aCmd += QString(" -n %1").arg(myFileIndex+1);
1560     aCmd += QString(" -j \"%1\"").arg(aPattern);
1561     aCmd += " | yuv2lav";
1562     aCmd += QString(" -o \"%1\"").arg(myDumpPath->GetPath());
1563   #ifdef WIN32
1564     aCmd += " -f aA";   
1565   #endif
1566     system(aCmd.toLatin1().data());
1567
1568     // remove temporary jpeg files
1569 #ifndef WIN32
1570     aCmd = "( ";
1571     aCmd += QString("cd %1").arg(aDirPath);
1572     aCmd += "; ls";
1573     aCmd += QString(" | egrep '%1_[0-9]*.jpeg'").arg(aBaseName);
1574     aCmd += " | xargs rm";
1575     aCmd += " )";
1576 #else
1577   QString tmpFile = QString("_") + aBaseName + "_tempfile";
1578   QString diskName = aDirPath.split("/")[0];
1579   aCmd = diskName + " && (cd " + aDirPath.replace("/","\\\\") + 
1580     " && ((dir /b | findstr " + aBaseName + "_[0-9]*.jpeg > " + tmpFile + 
1581     ") & (for /f %i in (" + tmpFile + ") do (del \"%i\")) & (del " + tmpFile + "))) > NUL";
1582 #endif
1583     system(aCmd.toLatin1().data());
1584   }
1585
1586   if (myExecutionState->IsActive())
1587     ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>(this,&VISU_TimeAnimation::_emitStopped));
1588   myExecutionState->SetActive(false);
1589 }
1590
1591 //------------------------------------------------------------------------
1592 VISU::Result_i* VISU_TimeAnimation::createPresent (_PTR(SObject) theField)
1593 {
1594   _PTR(SObject) aSObj = theField->GetFather();
1595   aSObj = aSObj->GetFather();
1596   aSObj = aSObj->GetFather();
1597   CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj);
1598   if (CORBA::is_nil(anObject)) return NULL;
1599   return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
1600 }
1601
1602 //------------------------------------------------------------------------
1603 double VISU_TimeAnimation::getTimeValue (_PTR(SObject) theTimeStamp)
1604 {
1605   _PTR(GenericAttribute) anAttr;
1606   if (theTimeStamp->FindAttribute(anAttr, "AttributeName")) {
1607     _PTR(AttributeName) aName (anAttr);
1608     QString aNameString (aName->Value().c_str());
1609     int time_len = aNameString.indexOf(',');
1610     if (time_len > -1)
1611       return aNameString.left(time_len).toDouble();
1612     else
1613       return aNameString.toDouble();
1614   }
1615   return -1.0;
1616 }
1617
1618 //------------------------------------------------------------------------
1619 void VISU_TimeAnimation::setSpeed(CORBA::Long theSpeed)
1620 {
1621   mySpeed = (theSpeed<1)? 1 : theSpeed;
1622 }
1623
1624 //------------------------------------------------------------------------
1625 void VISU_TimeAnimation::setAnimationSequence(const char* theSequence)
1626 {
1627   mySequence = QString( theSequence );
1628 }
1629
1630 //------------------------------------------------------------------------
1631 char* VISU_TimeAnimation::getAnimationSequence()
1632 {
1633   return strdup( mySequence.toLatin1().data() );
1634 }
1635
1636 //------------------------------------------------------------------------
1637 CORBA::Boolean VISU_TimeAnimation::isSequenceDefined()
1638 {
1639   return !mySequence.isEmpty();
1640 }
1641
1642 //------------------------------------------------------------------------
1643 bool VISU_TimeAnimation::getIndicesFromSequence( QString theSequence, QList<long>& theIndices )
1644 {
1645   bool isCorrect = true;
1646
1647   theIndices.clear();
1648
1649   QStringList aList = theSequence.split( ",", QString::SkipEmptyParts );
1650   QStringList::iterator it = aList.begin();
1651   QStringList::iterator itEnd = aList.end();
1652   for( ; it != itEnd; ++it )
1653   {
1654     if( !isCorrect )
1655       break;
1656
1657     isCorrect = false;
1658
1659     QString aString = *it;
1660     if( aString.isEmpty() )
1661       continue;
1662
1663     bool ok = false;
1664     int aSingleIndex = aString.toLong( &ok );
1665     if( ok )
1666     {
1667       theIndices.append( aSingleIndex );
1668       isCorrect = true;
1669     }
1670     else if( aString.contains( '-' ) == 1 )
1671     {
1672       QString aLeftIndexStr = aString.section( '-', 0, 0 );
1673       QString aRightIndexStr = aString.section( '-', -1 );
1674
1675       ok = false;
1676       int aLeftIndex = aLeftIndexStr.toLong( &ok );
1677       if( !ok )
1678         continue;
1679
1680       ok = false;
1681       int aRightIndex = aRightIndexStr.toLong( &ok );
1682       if( !ok )
1683         continue;
1684
1685       if( aLeftIndex >= aRightIndex )
1686         continue;
1687
1688       for( int i = aLeftIndex; i <= aRightIndex; i++ )
1689         theIndices.append( i );
1690
1691       isCorrect = true;
1692     }
1693   }
1694
1695   return isCorrect;
1696 }
1697
1698 //------------------------------------------------------------------------
1699 void VISU_TimeAnimation::dumpTo(const char* thePath)
1700 {
1701   myDumpPath->SetPath( QString( thePath ) );
1702 }
1703
1704 //------------------------------------------------------------------------
1705 std::string VISU_TimeAnimation::setDumpFormat(const char* theFormat)
1706 {
1707   myDumpFormat = theFormat;
1708   QList<QByteArray> aDumpFormats = QImageWriter::supportedImageFormats();
1709   if (myDumpFormat.isEmpty() || 
1710       (aDumpFormats.indexOf(theFormat) < 0 && myDumpFormat.compare("AVI") != 0)) {
1711     if (aDumpFormats.indexOf("JPEG") >= 0 ||
1712         aDumpFormats.indexOf("jpeg") >= 0)
1713       myDumpFormat = "JPEG";
1714     else
1715       myDumpFormat = aDumpFormats.at(0);
1716   }
1717   return myDumpFormat.toLatin1().data();
1718 }
1719
1720 //------------------------------------------------------------------------
1721 void VISU_TimeAnimation::setTimeStampFrequency(CORBA::Long theFrequency)
1722 {
1723   myTimeStampFrequency = theFrequency;
1724 }
1725
1726 //------------------------------------------------------------------------
1727 bool VISU_TimeAnimation::checkAVIMaker() const
1728 {
1729   QList<QByteArray> aDumpFormats = QImageWriter::supportedImageFormats();
1730   if (aDumpFormats.indexOf("JPEG") < 0 &&
1731       aDumpFormats.indexOf("jpeg") < 0)
1732     return false;
1733
1734   QString aCmd;
1735 #ifndef WIN32
1736   aCmd = "which " + myAVIMaker + " 2> /dev/null";
1737 #else
1738   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";
1739 #endif
1740   int iErr = system(aCmd.toLatin1().data());
1741   return (iErr == 0);
1742 }
1743
1744 //************************************************************************
1745 int VISU_TimeAnimation::myNBAnimations = 0;
1746 QString VISU_TimeAnimation::GenerateName()
1747 {
1748   return VISU::GenerateName("Animation", myNBAnimations++);
1749 }
1750
1751 //------------------------------------------------------------------------
1752 std::string GetPresentationComment (VISU::VISUType thePrsType)
1753 {
1754   std::string aPrsCmt;
1755   switch (thePrsType) {
1756   case VISU::TSCALARMAP:
1757     aPrsCmt = VISU::ScalarMap_i::myComment;
1758     break;
1759   case VISU::TISOSURFACES:
1760     aPrsCmt = VISU::IsoSurfaces_i::myComment;
1761     break;
1762   case VISU::TCUTPLANES:
1763     aPrsCmt = VISU::CutPlanes_i::myComment;
1764     break;
1765   case VISU::TCUTLINES:
1766     aPrsCmt = VISU::CutLines_i::myComment;
1767     break;
1768   case VISU::TCUTSEGMENT:
1769     aPrsCmt = VISU::CutSegment_i::myComment;
1770     break;
1771   case VISU::TPLOT3D:
1772     aPrsCmt = VISU::Plot3D_i::myComment;
1773     break;
1774   case VISU::TDEFORMEDSHAPE:
1775     aPrsCmt = VISU::DeformedShape_i::myComment;
1776     break;
1777   case VISU::TVECTORS:
1778     aPrsCmt = VISU::Vectors_i::myComment;
1779     break;
1780   case VISU::TSTREAMLINES:
1781     aPrsCmt = VISU::StreamLines_i::myComment;
1782     break;
1783   case VISU::TGAUSSPOINTS:
1784     aPrsCmt = VISU::GaussPoints_i::myComment;
1785     break;
1786   case VISU::TSCALARMAPONDEFORMEDSHAPE:
1787   case VISU::TDEFORMEDSHAPEANDSCALARMAP:
1788     aPrsCmt = VISU::DeformedShapeAndScalarMap_i::myComment;
1789     break;
1790   default:
1791     aPrsCmt = "Unknown presentation";
1792     break;
1793   }
1794   return aPrsCmt;
1795 }
1796
1797 //------------------------------------------------------------------------
1798 SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
1799 {
1800   if (myStudy->GetProperties()->IsLocked()) {
1801     SUIT_MessageBox::warning(0,
1802                              QObject::tr("WRN_VISU_WARNING"),
1803                              QObject::tr("WRN_STUDY_LOCKED"),
1804                              QObject::tr("BUT_OK"));
1805     return SALOMEDS::SObject::_nil();
1806   }
1807
1808   _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
1809   aStudyBuilder->NewCommand();  // There is a transaction
1810   _PTR(SComponent) aSComponent = VISU::ClientFindOrCreateVisuComponent(myStudy);
1811   std::string aSComponentEntry = aSComponent->GetID();
1812
1813   QString aComment;
1814   aComment.sprintf("myComment=ANIMATION;myTimeMinVal=%g;myTimeMaxVal=%g;mySequence=%s;myMode=%d",
1815                    myTimeMinVal,
1816                    myTimeMaxVal,
1817                    mySequence.toLatin1().data(),
1818                    myAnimationMode);
1819
1820   string anEntry = VISU::CreateAttributes(myStudy,
1821                                           aSComponentEntry.c_str(),
1822                                           VISU::NO_ICON,
1823                                           VISU::NO_IOR,
1824                                           GenerateName().toLatin1().data(),
1825                                           VISU::NO_PERFSITENT_REF,
1826                                           aComment.toLatin1().data(),
1827                                           true);
1828   myAnimEntry = anEntry.c_str();
1829   _PTR(SObject) aAnimSObject = myStudy->FindObjectID(anEntry.c_str());
1830
1831   for (int i = 0; i < getNbFields(); i++) {
1832     FieldData& aData = myFieldsLst[i];
1833     if (aData.myPrs.empty()) {
1834       generatePresentations(i);
1835     }
1836     if ( !aData.myPrs.empty() ) {
1837       _PTR(SObject) newObj = aStudyBuilder->NewObject(aAnimSObject);
1838       aStudyBuilder->Addreference(newObj, aData.myField);
1839       
1840       ostringstream strOut;
1841       aData.myPrs[0]->ToStream(strOut);
1842       string aPrsComment = strOut.str();
1843       string aPrsMyComment = aData.myPrs[0]->GetComment();
1844       if(aPrsMyComment == "PRSMERGER")
1845         aPrsMyComment = "SCALARMAP";
1846       VISU::CreateAttributes(myStudy, 
1847                              newObj->GetID().c_str(),
1848                              VISU::NO_ICON,
1849                              VISU::NO_IOR,
1850                              aPrsMyComment.c_str(),
1851                              VISU::NO_PERFSITENT_REF,
1852                              aPrsComment.c_str(),
1853                              true);
1854     }
1855   }
1856   aStudyBuilder->CommitCommand();
1857
1858   return VISU::GetSObject(aAnimSObject)._retn();
1859 }
1860
1861 //------------------------------------------------------------------------
1862 void VISU_TimeAnimation::saveAnimation()
1863 {
1864   if (myStudy->GetProperties()->IsLocked()) return;
1865   if (myAnimEntry.isEmpty()) return;
1866
1867   _PTR(SObject) aAnimSObject = myStudy->FindObjectID(myAnimEntry.toLatin1().data());
1868   if (!aAnimSObject) return;
1869
1870   _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
1871   aStudyBuilder->NewCommand();  // There is a transaction
1872   _PTR(SComponent) aSComponent = VISU::ClientFindOrCreateVisuComponent(myStudy);
1873   std::string aSComponentEntry = aSComponent->GetID();
1874
1875   QString aComment;
1876   aComment.sprintf("myComment=ANIMATION;myTimeMinVal=%g;myTimeMaxVal=%g;mySequence=%s;myMode=%d",
1877                    myTimeMinVal,
1878                    myTimeMaxVal,
1879                    mySequence.toLatin1().data(),
1880                    myAnimationMode);
1881
1882   _PTR(GenericAttribute) anAttr;
1883   anAttr = aStudyBuilder->FindOrCreateAttribute(aAnimSObject, "AttributeString");
1884   _PTR(AttributeString) aCmnt (anAttr);
1885   aCmnt->SetValue(aComment.toLatin1().data());
1886
1887   _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
1888   int i = 0, nbf = getNbFields();
1889   for (anIter->Init(); anIter->More(); anIter->Next(), i++) {
1890     if (i >= nbf) break; // it must not be
1891     FieldData& aData = myFieldsLst[i];
1892
1893     // Get presentation name and comment
1894     if (aData.myPrs.empty()) {
1895       generatePresentations(i);
1896     }
1897     ostringstream strOut;
1898     aData.myPrs[0]->ToStream(strOut);
1899     string aPrsComment = strOut.str();
1900     string aPrsNameTxt = aData.myPrs[0]->GetComment();
1901     if(aPrsNameTxt == "PRSMERGER")
1902       aPrsNameTxt = "SCALARMAP";
1903     // Save in study
1904     _PTR(SObject) aRefObj = anIter->Value();
1905     _PTR(ChildIterator) anPrsIter = myStudy->NewChildIterator(aRefObj);
1906     anPrsIter->Init();
1907
1908     if (anPrsIter->More()) {
1909       _PTR(SObject) aPrsObj = anPrsIter->Value();
1910       anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeString");
1911       aCmnt = _PTR(AttributeString)(anAttr);
1912       aCmnt->SetValue(aPrsComment.c_str());
1913
1914       anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeName");
1915       _PTR(AttributeName) aPrsName (anAttr);
1916       aPrsName->SetValue(aPrsNameTxt);
1917
1918     } else {
1919       VISU::CreateAttributes(myStudy, 
1920                              aRefObj->GetID().c_str(),
1921                              VISU::NO_ICON,
1922                              VISU::NO_IOR,
1923                              aPrsNameTxt.c_str(),
1924                              VISU::NO_PERFSITENT_REF,
1925                              aPrsComment.c_str(),
1926                              true);
1927     }
1928   }
1929   aStudyBuilder->CommitCommand();
1930 }
1931
1932 //------------------------------------------------------------------------
1933 void VISU_TimeAnimation::restoreFromStudy(SALOMEDS::SObject_ptr theField)
1934 {
1935   _PTR(SObject) aAnimSObject = VISU::GetClientSObject(theField, myStudy);
1936   restoreFromStudy(aAnimSObject);
1937 }
1938
1939 void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
1940 {
1941   _PTR(SObject) aAnimSObject = theField;
1942
1943   VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aAnimSObject);
1944   if (aMap.empty()) 
1945     return;
1946
1947   bool isExist;
1948   myTimeMinVal = VISU::Storable::FindValue(aMap,"myTimeMinVal",&isExist).toDouble();
1949   myTimeMaxVal = VISU::Storable::FindValue(aMap,"myTimeMaxVal",&isExist).toDouble();
1950   mySequence = VISU::Storable::FindValue(aMap,"mySequence",&isExist);
1951   myAnimationMode = VISU::Animation::AnimationMode(VISU::Storable::FindValue(aMap,"myMode",&isExist).toInt());
1952
1953   _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
1954   for (anIter->Init(); anIter->More(); anIter->Next()) {
1955     _PTR(SObject) aRefObj = anIter->Value();
1956     _PTR(SObject) aFieldObj;
1957
1958     if (!aRefObj->ReferencedObject(aFieldObj) ) 
1959       continue;
1960
1961     int nbAttr = aFieldObj->GetAllAttributes().size();
1962     //std::string name1 = aFieldObj->GetName();
1963     if(nbAttr<1)
1964       continue;
1965
1966     addField(aFieldObj);
1967     if ( isRangeDefined() || isSequenceDefined() ) 
1968       myFieldsAbsFrames.pop_back();
1969
1970     FieldData& aData = getFieldData(getNbFields()-1);
1971     
1972     // Get Presentation object
1973     _PTR(ChildIterator) anPrsIter = myStudy->NewChildIterator(aRefObj);
1974     anPrsIter->Init();
1975     if (!anPrsIter->More()) 
1976       continue;
1977     _PTR(SObject) aPrsObj = anPrsIter->Value();
1978     _PTR(GenericAttribute) anAttr;
1979     if (!aPrsObj->FindAttribute(anAttr, "AttributeName")) 
1980       continue;
1981     _PTR(AttributeName) aName (anAttr);
1982     string aStr = aName->Value();
1983     QString strName (aStr.c_str());
1984
1985     if (strName == VISU::ScalarMap_i::myComment.c_str())
1986       aData.myPrsType = VISU::TSCALARMAP;
1987     else if (strName == VISU::IsoSurfaces_i::myComment.c_str())
1988       aData.myPrsType = VISU::TISOSURFACES;
1989     else if (strName == VISU::CutPlanes_i::myComment.c_str())
1990       aData.myPrsType = VISU::TCUTPLANES;
1991     else if (strName == VISU::CutLines_i::myComment.c_str())
1992       aData.myPrsType = VISU::TCUTLINES;
1993     else if (strName == VISU::CutSegment_i::myComment.c_str())
1994       aData.myPrsType = VISU::TCUTSEGMENT;
1995     else if (strName == VISU::Plot3D_i::myComment.c_str())
1996       aData.myPrsType = VISU::TPLOT3D;
1997     else if (strName == VISU::DeformedShape_i::myComment.c_str())
1998       aData.myPrsType = VISU::TDEFORMEDSHAPE;
1999     else if (strName == VISU::Vectors_i::myComment.c_str())
2000       aData.myPrsType = VISU::TVECTORS;
2001     else if (strName == VISU::StreamLines_i::myComment.c_str())
2002       aData.myPrsType = VISU::TSTREAMLINES;
2003     else if (strName == VISU::GaussPoints_i::myComment.c_str())
2004       aData.myPrsType = VISU::TGAUSSPOINTS;
2005     else if (strName == VISU::DeformedShapeAndScalarMap_i::myComment.c_str())
2006       aData.myPrsType = VISU::TDEFORMEDSHAPEANDSCALARMAP;
2007     else
2008       continue;
2009     generatePresentations(getNbFields()-1);
2010
2011     VISU::Storable::TRestoringMap aPrsMap = VISU::Storable::GetStorableMap(aPrsObj);
2012     if (aPrsMap.empty())
2013       continue;
2014     if (aData.myPrs[0]) {
2015       aData.myPrs[0]->Restore(VISU::GetSObject(aData.myField), aPrsMap);
2016       aData.myPrs[0]->GetOffset(aData.myOffset);
2017     }
2018     for (int i = 1; i < aData.myNbFrames; i++) {
2019       if (!aData.myPrs[0])
2020         continue;
2021       bool anIsFixedRange = false;
2022       if (aData.myPrsType != VISU::TGAUSSPOINTS) {
2023         if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
2024           anIsFixedRange = aPrs->IsRangeFixed();
2025       }
2026       if (aData.myPrsType == VISU::TDEFORMEDSHAPEANDSCALARMAP) {
2027         if (VISU::DeformedShapeAndScalarMap_i* aDeformedPrs =
2028             dynamic_cast<VISU::DeformedShapeAndScalarMap_i*>(aData.myPrs[i])) {
2029           //Set correct time stamp number
2030           int aTimeStampNum = aDeformedPrs->GetScalarTimeStampNumber();
2031           aDeformedPrs->SameAs(aData.myPrs[0]);
2032           aDeformedPrs->SetScalarField(aDeformedPrs->GetScalarEntity(),
2033                                        aDeformedPrs->GetScalarFieldName(),
2034                                        aTimeStampNum);
2035         }
2036       }
2037       else
2038         aData.myPrs[i]->SameAs(aData.myPrs[0]);
2039     }
2040   }
2041   string aStr = aAnimSObject->GetID();
2042   myAnimEntry = aStr.c_str();
2043 }
2044
2045 void VISU_TimeAnimation::onViewDeleted()
2046 {
2047   myView = 0;
2048   stopAnimation();
2049 }
2050
2051 void VISU_TimeAnimation::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs)
2052   throw (SALOME::SALOME_Exception)
2053 {
2054   Unexpect aCatch(SALOME_SalomeException);
2055
2056   VISU::ColoredPrs3d_i* aPrs_i = dynamic_cast<VISU::ColoredPrs3d_i*>(GetServant(thePrs).in());
2057
2058   if ( !aPrs_i ) 
2059     THROW_SALOME_CORBA_EXCEPTION("Error : invalid dynamic cast of the given presentation to VISU::ColoredPrs3d_i",
2060                                  SALOME::INTERNAL_ERROR);
2061   
2062   if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode
2063     FieldData& aData = myFieldsLst[theFieldNum];
2064     
2065     if ( aData.myPrs.empty() )
2066       THROW_SALOME_CORBA_EXCEPTION("Error : presentations for the given field is not yet created!",
2067                                    SALOME::INTERNAL_ERROR);
2068     
2069     if ( aPrs_i->GetCResult() != aData.myPrs[0]->GetCResult() )
2070       THROW_SALOME_CORBA_EXCEPTION("Error : the MED file is not the same!",
2071                                    SALOME::INTERNAL_ERROR);
2072     
2073     for (int i = 0; i < aData.myNbFrames; i++) {
2074       bool anIsFixedRange = false;
2075       if (aData.myPrsType != VISU::TGAUSSPOINTS) {
2076         if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(aData.myPrs[i]))
2077           anIsFixedRange = aPrs->IsRangeFixed();
2078       }
2079       aData.myPrs[i]->SameAs(aPrs_i);
2080     }
2081   }
2082   else if ( myAnimationMode == VISU::Animation::SUCCESSIVE ) { // successive animation mode
2083     for (int f = 0; f < getNbFields(); f++) {
2084       FieldData& aData = myFieldsLst[f];
2085       
2086       if ( aData.myPrs.empty() )
2087         THROW_SALOME_CORBA_EXCEPTION("Error : presentations for the given field is not yet created!",
2088                                      SALOME::INTERNAL_ERROR);
2089       
2090       for (int i = 0; i < aData.myNbFrames; i++) {
2091         aData.myPrs[i]->SameAs(aPrs_i);
2092       }
2093     }
2094   }
2095 }
2096
2097 //========================================================================
2098 //========================================================================
2099 //========================================================================
2100 struct TNewAnimationEvent: public SALOME_Event
2101 {
2102   std::string myStudyName;
2103   VISU::View3D_ptr myView3D;
2104
2105   typedef VISU_TimeAnimation* TResult;
2106   TResult myResult;
2107
2108   TNewAnimationEvent (std::string theStudyName, VISU::View3D_ptr theView3D):
2109     myStudyName(theStudyName),
2110     myView3D(VISU::View3D::_duplicate(theView3D)),
2111     myResult(NULL)
2112   {}
2113
2114   virtual
2115   void
2116   Execute()
2117   {
2118     SUIT_Session* aSession = SUIT_Session::session();
2119     QList<SUIT_Application*> anApplications = aSession->applications();
2120     QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
2121     while ( anIter !=  anApplications.end() ) {
2122       SUIT_Application* anApp = *anIter;
2123       if (SUIT_Study* aSStudy = anApp->activeStudy()) {
2124         if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
2125           if (_PTR(Study) aCStudy = aStudy->studyDS()) {
2126             if (myStudyName == aCStudy->Name()) {
2127               myResult = new VISU_TimeAnimation (aCStudy, myView3D);
2128               break;
2129             }
2130           }
2131         }
2132       }
2133       anIter++;
2134     }
2135   }
2136 };
2137
2138 VISU_TimeAnimation_i::VISU_TimeAnimation_i (SALOMEDS::Study_ptr theStudy,
2139                                             VISU::View3D_ptr theView3D)
2140 {
2141   std::string aStudyName = theStudy->Name();
2142   myAnim = ProcessEvent(new TNewAnimationEvent (aStudyName, theView3D));
2143 }
2144
2145 VISU_TimeAnimation_i::~VISU_TimeAnimation_i()
2146 {
2147   delete myAnim;
2148 }
2149
2150 bool VISU_TimeAnimation_i::addField (SALOMEDS::SObject_ptr theField)
2151 {
2152   return myAnim->addField(theField);
2153 }
2154
2155 void VISU_TimeAnimation_i::clearFields ()
2156 {
2157   for (int i = 0; i < myAnim->getNbFields(); i++) {
2158     myAnim->clearData(myAnim->getFieldData(i));
2159   }
2160   myAnim->clearFieldData();
2161 }
2162
2163 CORBA::Boolean VISU_TimeAnimation_i::generateFrames()
2164 {
2165   //return ProcessEvent(new TMemFunEvent<VISU_TimeAnimation,bool>
2166   //                    (myAnim,&VISU_TimeAnimation::generateFrames));
2167   return myAnim->generateFrames();
2168 }
2169
2170 void VISU_TimeAnimation_i::generatePresentations (CORBA::Long theFieldNum)
2171 {
2172   myAnim->generatePresentations(theFieldNum);
2173 }
2174
2175 void VISU_TimeAnimation_i::clearView()
2176 {
2177   //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2178   //                 (myAnim,&VISU_TimeAnimation::clearView));
2179   myAnim->clearView();
2180 }
2181
2182 void VISU_TimeAnimation_i::stopAnimation()
2183 {
2184   //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2185   //                 (myAnim,&VISU_TimeAnimation::stopAnimation));
2186   myAnim->stopAnimation();
2187 }
2188
2189 void VISU_TimeAnimation_i::startAnimation()
2190 {
2191   //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2192   //                 (myAnim,&VISU_TimeAnimation::startAnimation));
2193   myAnim->startAnimation();
2194 }
2195
2196 void VISU_TimeAnimation_i::nextFrame()
2197 {
2198   //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2199   //                 (myAnim,&VISU_TimeAnimation::nextFrame));
2200   myAnim->nextFrame();
2201 }
2202
2203 void VISU_TimeAnimation_i::prevFrame()
2204 {
2205   //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2206   //                 (myAnim,&VISU_TimeAnimation::prevFrame));
2207   myAnim->prevFrame();
2208 }
2209
2210 void VISU_TimeAnimation_i::firstFrame()
2211 {
2212   //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2213   //                 (myAnim,&VISU_TimeAnimation::firstFrame));
2214   myAnim->firstFrame();
2215 }
2216
2217 void VISU_TimeAnimation_i::lastFrame()
2218 {
2219   //ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
2220   //                 (myAnim,&VISU_TimeAnimation::lastFrame));
2221   myAnim->lastFrame();
2222 }
2223
2224 void VISU_TimeAnimation_i::gotoFrame(CORBA::Long theFrame)
2225 {
2226   //ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,CORBA::Long>
2227   //                 (myAnim,&VISU_TimeAnimation::gotoFrame,theFrame));
2228   myAnim->gotoFrame(theFrame);
2229 }
2230
2231 CORBA::Long VISU_TimeAnimation_i::getNbFields()
2232 {
2233   return myAnim->getNbFields();
2234 }
2235
2236 CORBA::Long VISU_TimeAnimation_i::getNbFrames()
2237 {
2238   return myAnim->getNbFrames();
2239 }
2240
2241 CORBA::Boolean VISU_TimeAnimation_i::isRunning()
2242 {
2243   return myAnim->isRunning();
2244 }
2245
2246 CORBA::Long VISU_TimeAnimation_i::getCurrentFrame()
2247 {
2248   return myAnim->getCurrentFrame();
2249 }
2250
2251 VISU::ColoredPrs3d_ptr VISU_TimeAnimation_i::getPresentation
2252                     (CORBA::Long theField, CORBA::Long theFrame)
2253 {
2254   return myAnim->getPresentation(theField,theFrame);
2255 }
2256
2257 void VISU_TimeAnimation_i::setPresentationType (CORBA::Long theFieldNum,
2258                                                 VISU::VISUType theType)
2259 {
2260   myAnim->setPresentationType(theFieldNum,theType);
2261 }
2262
2263 VISU::VISUType VISU_TimeAnimation_i::getPresentationType (CORBA::Long theFieldNum)
2264 {
2265   return myAnim->getPresentationType(theFieldNum);
2266 }
2267
2268 void VISU_TimeAnimation_i::setSpeed(CORBA::Long theSpeed)
2269 {
2270   myAnim->setSpeed(theSpeed);
2271 }
2272
2273 CORBA::Long VISU_TimeAnimation_i::getSpeed()
2274 {
2275   return myAnim->getSpeed();
2276 }
2277
2278 CORBA::Boolean VISU_TimeAnimation_i::isProportional()
2279 {
2280   return myAnim->isProportional();
2281 }
2282
2283 void VISU_TimeAnimation_i::setAnimationRange (CORBA::Double theMin,
2284                                               CORBA::Double theMax)
2285 {
2286   myAnim->setAnimationRange(theMin,theMax);
2287 }
2288
2289 CORBA::Double VISU_TimeAnimation_i::getMinRange()
2290 {
2291   return myAnim->getMinRange();
2292 }
2293
2294 CORBA::Double VISU_TimeAnimation_i::getMaxRange()
2295 {
2296   return myAnim->getMaxRange();
2297 }
2298
2299 CORBA::Boolean VISU_TimeAnimation_i::isRangeDefined()
2300 {
2301   return myAnim->isRangeDefined();
2302 }
2303
2304 void VISU_TimeAnimation_i::setAnimationSequence (const char* theSequence)
2305 {
2306   myAnim->setAnimationSequence(theSequence);
2307 }
2308
2309 char* VISU_TimeAnimation_i::getAnimationSequence()
2310 {
2311   return myAnim->getAnimationSequence();
2312 }
2313
2314 CORBA::Boolean VISU_TimeAnimation_i::isSequenceDefined()
2315 {
2316   return myAnim->isSequenceDefined();
2317 }
2318
2319 void VISU_TimeAnimation_i::dumpTo (const char* thePath)
2320 {
2321   myAnim->dumpTo(thePath);
2322 }
2323
2324 char* VISU_TimeAnimation_i::setDumpFormat (const char* theFormat)
2325 {
2326   string aDumpFormat = myAnim->setDumpFormat(theFormat);
2327   return CORBA::string_dup(aDumpFormat.c_str());
2328 }
2329
2330 void VISU_TimeAnimation_i::setTimeStampFrequency(CORBA::Long theFrequency)
2331 {
2332   myAnim->setTimeStampFrequency(theFrequency);
2333 }
2334
2335 CORBA::Long VISU_TimeAnimation_i::getTimeStampFrequency()
2336 {
2337   return myAnim->getTimeStampFrequency();
2338 }
2339
2340 CORBA::Boolean VISU_TimeAnimation_i::isCycling()
2341 {
2342   return myAnim->isCycling();
2343 }
2344
2345 CORBA::Boolean VISU_TimeAnimation_i::isCleaningMemoryAtEachFrame(){
2346   return myAnim->isCleaningMemoryAtEachFrame();
2347 }
2348
2349 CORBA::Double VISU_TimeAnimation_i::getMinTime()
2350 {
2351   return myAnim->getMinTime();
2352 }
2353
2354 CORBA::Double VISU_TimeAnimation_i::getMaxTime()
2355 {
2356   return myAnim->getMaxTime();
2357 }
2358
2359 void VISU_TimeAnimation_i::setProportional (CORBA::Boolean theProp)
2360 {
2361   myAnim->setProportional(theProp);
2362 }
2363
2364 void VISU_TimeAnimation_i::setCycling (CORBA::Boolean theCycle)
2365 {
2366   myAnim->setCycling(theCycle);
2367 }
2368
2369 void VISU_TimeAnimation_i::setCleaningMemoryAtEachFrame(CORBA::Boolean theCycle){
2370   myAnim->setCleaningMemoryAtEachFrame(theCycle);
2371 }
2372
2373 SALOMEDS::SObject_ptr VISU_TimeAnimation_i::publishInStudy()
2374 {
2375   return myAnim->publishInStudy();
2376 }
2377
2378 void VISU_TimeAnimation_i::restoreFromStudy(SALOMEDS::SObject_ptr theObj)
2379 {
2380   myAnim->restoreFromStudy(theObj);
2381 }
2382
2383 CORBA::Boolean VISU_TimeAnimation_i::isSavedInStudy()
2384 {
2385   return myAnim->isSavedInStudy();
2386 }
2387
2388 void VISU_TimeAnimation_i::saveAnimation()
2389 {
2390   myAnim->saveAnimation();
2391 }
2392
2393 void VISU_TimeAnimation_i::setAnimationMode(VISU::Animation::AnimationMode theMode)
2394 {
2395   myAnim->setAnimationMode(theMode);
2396 }
2397
2398 VISU::Animation::AnimationMode VISU_TimeAnimation_i::getAnimationMode()
2399 {
2400   return VISU::Animation::AnimationMode(myAnim->getAnimationMode());
2401 }
2402
2403 void VISU_TimeAnimation_i::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs)
2404   throw (SALOME::SALOME_Exception)
2405 {
2406   myAnim->ApplyProperties(theFieldNum, thePrs);
2407 }