Salome HOME
b337e3ada5c446474d6bd7cef5ab5a41c5666690
[modules/visu.git] / src / VISU_I / VISU_TimeAnimation.cxx
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
4 //  This library is free software; you can redistribute it and/or 
5 //  modify it under the terms of the GNU Lesser General Public 
6 //  License as published by the Free Software Foundation; either 
7 //  version 2.1 of the License. 
8 // 
9 //  This library is distributed in the hope that it will be useful, 
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 //  Lesser General Public License for more details. 
13 // 
14 //  You should have received a copy of the GNU Lesser General Public 
15 //  License along with this library; if not, write to the Free Software 
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 // 
18 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : VISU_TimeAnimation.cxx
21 //  Author : Vitaly SMETANNIKOV
22 //  Module : VISU
23
24 #include "VISU_TimeAnimation.h"
25
26 #include "VISUConfig.hh"
27
28 #include "VISU_Result_i.hh"
29 #include "VISU_Prs3d_i.hh"
30 #include "VISU_Mesh_i.hh"
31 #include "VISU_ScalarMap_i.hh"
32 #include "VISU_IsoSurfaces_i.hh"
33 #include "VISU_DeformedShape_i.hh"
34 #include "VISU_ScalarMapOnDeformedShape_i.hh"
35 #include "VISU_CutPlanes_i.hh"
36 #include "VISU_Plot3D_i.hh"
37 #include "VISU_CutLines_i.hh"
38 #include "VISU_Vectors_i.hh"
39 #include "VISU_StreamLines_i.hh"
40 #include "VISU_GaussPoints_i.hh"
41 #include "VISU_ViewManager_i.hh"
42 #include "VISU_View_i.hh"
43
44 #include "VISU_ScalarBarActor.hxx"
45 #include "VISU_Actor.h"
46
47 #include "SalomeApp_Study.h"
48
49 #include "SVTK_ViewWindow.h"
50
51 #include "SALOME_Event.hxx"
52
53 #include "SUIT_ResourceMgr.h"
54 #include "SUIT_Application.h"
55 #include "SUIT_Session.h"
56 #include "SUIT_Study.h"
57
58 #include "SALOMEDSClient_AttributeComment.hxx"
59 #include "SALOMEDSClient_AttributeName.hxx"
60 #include "CASCatch.hxx"
61
62 #include <qpixmap.h>
63 #include <qimage.h>
64 #include <qstrlist.h>
65 #include <qdir.h>
66
67 using namespace std;
68
69
70 //------------------------------------------------------------------------
71 VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
72                                         VISU::View3D_ptr theView3D)
73 {
74   myStudy = theStudy;
75   myIsActive = false;
76   myFrame = 0;
77   mySpeed = 1;
78   myProportional = false;
79   myView = 0;
80
81   if (!CORBA::is_nil(theView3D)) {
82     VISU::View3D_i* pView = dynamic_cast<VISU::View3D_i*>(GetServant(theView3D).in());
83     SUIT_ViewWindow* aVW = pView->GetViewWindow();
84     myView = dynamic_cast<SVTK_ViewWindow*>(aVW);
85     connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) );
86   }
87
88   myTimeMinVal = 0;
89   myTimeMaxVal = 0;
90   myTimeMin = 0;
91   myTimeMax = 0;
92   myLastError = "";
93   myCycling = false;
94
95   myAnimEntry = "";
96
97   myDumpPath = "";
98   myAVIMaker = "jpeg2yuv";
99 }
100
101
102 //------------------------------------------------------------------------
103 VISU_TimeAnimation::~VISU_TimeAnimation()
104 {
105   if (!myView) {
106     MESSAGE("Viewer is not defined for animation");
107     return;
108   }
109
110   for (int i = 0; i < getNbFields(); i++) {
111     clearData(myFieldsLst[i]);
112   }
113
114   /* Terminates the execution of the thread. 
115    * The thread may or may not be terminated immediately, 
116    * depending on the operating system's scheduling policies. 
117    *  
118    * Use QThread::wait() after terminate() for synchronous termination.
119    *
120    * When the thread is terminated, all threads waiting for the the thread to finish will be woken up.
121    * 
122    * Warning: This function is dangerous, and its use is discouraged. 
123    * The thread can be terminated at any point in its code path. 
124    * Threads can be terminated while modifying data. 
125    * There is no chance for the thread to cleanup after itself, 
126    * unlock any held mutexes, etc. In short, use this function only if absolutely necessary. 
127    */
128   myDumpPath = "";
129   QThread::wait(100);
130   QThread::terminate();
131   QThread::wait(400);
132 }
133
134
135 //------------------------------------------------------------------------
136 void VISU_TimeAnimation::addField (_PTR(SObject) theField)
137 {
138   FieldData aNewData;
139   aNewData.myField = theField;
140   aNewData.myNbFrames = 0;
141   aNewData.myPrsType = VISU::TSCALARMAP;
142   aNewData.myOffset[0] = aNewData.myOffset[1] = aNewData.myOffset[2] = 0;
143   VISU::Storable::TRestoringMap aMap = getMapOfValue(aNewData.myField);
144   aNewData.myNbTimes = VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
145   myFieldsLst.append(aNewData);
146
147   //find Min/Max timestamps
148   if ((myTimeMin == 0) && (myTimeMax == 0)) {
149     _PTR(ChildIterator) anIter = myStudy->NewChildIterator(theField);
150     anIter->Next(); // First is reference on support
151     myTimeMin = getTimeValue(anIter->Value());
152     for(; anIter->More(); anIter->Next()) {
153       myTimeMax = getTimeValue(anIter->Value());
154     }
155   }
156 }
157
158 //------------------------------------------------------------------------
159 void VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField)
160 {
161   SALOMEDS::SObject_var theFieldDup = SALOMEDS::SObject::_duplicate(theField);
162   _PTR(SObject) aField = VISU::GetClientSObject(theFieldDup, myStudy);
163   addField(aField);
164 }
165
166
167 //------------------------------------------------------------------------
168 void VISU_TimeAnimation::clearData(FieldData& theData) {
169   if (!myView) {
170     MESSAGE("Viewer is not defined for animation");
171     return;
172   }
173   theData.myTiming.clear();
174   vtkRenderer* aRen = myView->getRenderer();
175   if (!theData.myActors.empty()) {
176     for (int i = 0, iEnd = theData.myActors.size(); i < iEnd; i++) {
177       if (theData.myActors[i] != 0) {
178         theData.myActors[i]->RemoveFromRender(aRen);
179       }
180     }
181     theData.myActors.clear();
182   }
183   if (!theData.myPrs.empty()) {
184     for (int i = 0, iEnd = theData.myPrs.size(); i < iEnd; i++)
185       if (theData.myPrs[i] != 0) {
186         theData.myPrs[i]->_remove_ref();
187       }
188     theData.myPrs.clear();
189   }
190   theData.myNbFrames = 0;
191   myView->update();
192 }
193
194
195 namespace
196 {
197   //------------------------------------------------------------------------
198   template<class TPrs3d>
199   void
200   GeneratePresentations(_PTR(Study) theStudy,
201                         FieldData& theData,
202                         VISU::Result_i* theResult,
203                         bool theIsRangeDefined,
204                         CORBA::Double theTimeMin,
205                         CORBA::Double theTimeMax)
206   {
207     double aMin = VTK_LARGE_FLOAT, aMax = -VTK_LARGE_FLOAT;
208
209     _PTR(ChildIterator) anIter = theStudy->NewChildIterator(theData.myField);
210     anIter->Next(); // First is reference on support
211
212     long aFrameId = 0;
213     for(; anIter->More(); anIter->Next()){
214       if (aFrameId == theData.myNbTimes) {
215         MESSAGE("There are extra timestamps in field");
216         return;
217       }
218       _PTR(SObject) aTimeStamp = anIter->Value();
219       if(!aTimeStamp) 
220         continue;
221
222       theData.myTiming[aFrameId] = VISU_TimeAnimation::getTimeValue(aTimeStamp);
223       if (theIsRangeDefined) {
224         if (theData.myTiming[aFrameId] < theTimeMin) 
225           continue;
226         if (theData.myTiming[aFrameId] > theTimeMax) 
227           break;
228       }
229
230       VISU::Storable::TRestoringMap aTimeMap = VISU_TimeAnimation::getMapOfValue(aTimeStamp);
231       QString aMeshName = VISU::Storable::FindValue(aTimeMap,"myMeshName");
232       VISU::Entity anEntity = (VISU::Entity) VISU::Storable::FindValue(aTimeMap,"myEntityId").toInt();
233       QString aFieldName = VISU::Storable::FindValue(aTimeMap,"myFieldName");
234       int aTimeStampId = VISU::Storable::FindValue(aTimeMap,"myTimeStampId").toInt();
235       
236       bool anIsCreated = false;
237       TPrs3d* aPresent = new TPrs3d(theResult, false);
238       CASCatch_TRY{       
239         try{
240           if(aPresent->Create(aMeshName.latin1(),anEntity,aFieldName.latin1(),aTimeStampId)){
241             anIsCreated = true;
242             theData.myPrs[aFrameId++] = aPresent;
243             aMin = std::min(aPresent->GetMin(), aMin);
244             aMax = std::max(aPresent->GetMax(), aMax);
245           }
246         }catch(std::exception& exc){
247           INFOS("Follow exception was occured :\n"<<exc.what());
248         }catch(...){
249           INFOS("Unknown exception was occured!");
250         }
251       }CASCatch_CATCH(Standard_Failure) {
252         Handle(Standard_Failure) aFail = Standard_Failure::Caught();
253         INFOS("Follow signal was occured :\n"<<aFail->GetMessageString());
254       }
255       if(!anIsCreated)
256         aPresent->_remove_ref();
257     }
258     theData.myNbFrames = aFrameId;
259
260     if (theData.myPrsType != VISU::TGAUSSPOINTS){
261       int aRangeType = VISU::GetResourceMgr()->integerValue("VISU" , "scalar_range_type", 0);
262       if( aRangeType != 1 ){
263         for(long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++) {
264           if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(theData.myPrs[aFrameId])){
265             aPrs->SetRange(aMin, aMax);
266             aPrs->SetOffset(theData.myOffset);
267           }
268         }
269       }
270       if (theData.myPrsType == VISU::TISOSURFACE)
271         for (long aFrameId = 0; aFrameId < theData.myNbFrames; aFrameId++)
272           if (VISU::IsoSurfaces_i* aPrs = dynamic_cast<VISU::IsoSurfaces_i*>(theData.myPrs[aFrameId]))
273             aPrs->SetSubRange(aMin, aMax);
274     }
275   }
276 }
277   
278 void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) {
279   FieldData& aData = myFieldsLst[theFieldNum];
280
281   // Delete previous presentations
282   clearData(aData);
283
284   VISU::Result_i* aResult = createPresent(aData.myField);
285   VISU::Storable::TRestoringMap aMap = getMapOfValue(aData.myField);
286   aData.myNbFrames = aData.myNbTimes;
287   //VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
288
289   aData.myPrs.resize(aData.myNbTimes,NULL);
290   aData.myTiming.resize(aData.myNbTimes);
291
292   using namespace VISU;
293   switch (aData.myPrsType) {
294   case VISU::TSCALARMAP: // ScalarMap
295     GeneratePresentations<ScalarMap_i>(myStudy,
296                                        aData,
297                                        aResult,
298                                        isRangeDefined(),
299                                        myTimeMinVal,
300                                        myTimeMaxVal);
301     break;
302   case VISU::TISOSURFACE: // Iso Surfaces
303     GeneratePresentations<IsoSurfaces_i>(myStudy,
304                                          aData,
305                                          aResult,
306                                          isRangeDefined(),
307                                          myTimeMinVal,
308                                          myTimeMaxVal);
309     break;
310   case VISU::TCUTPLANES: // Cut Planes
311     GeneratePresentations<CutPlanes_i>(myStudy,
312                                        aData,
313                                        aResult,
314                                        isRangeDefined(),
315                                        myTimeMinVal,
316                                        myTimeMaxVal);
317     break;
318   case VISU::TCUTLINES: // Cut Lines
319     GeneratePresentations<CutLines_i>(myStudy,
320                                       aData,
321                                       aResult,
322                                       isRangeDefined(),
323                                       myTimeMinVal,
324                                       myTimeMaxVal);
325     break;
326   case VISU::TPLOT3D: // Plot3d
327     GeneratePresentations<Plot3D_i>(myStudy,
328                                     aData,
329                                     aResult,
330                                     isRangeDefined(),
331                                     myTimeMinVal,
332                                     myTimeMaxVal);
333     break;
334   case VISU::TDEFORMEDSHAPE: // Deformed Shape
335     GeneratePresentations<DeformedShape_i>(myStudy,
336                                            aData,
337                                            aResult,
338                                            isRangeDefined(),
339                                            myTimeMinVal,
340                                            myTimeMaxVal);
341     break;
342   case VISU::TVECTORS: // Vectors
343     GeneratePresentations<Vectors_i>(myStudy,
344                                      aData,
345                                      aResult,
346                                      isRangeDefined(),
347                                      myTimeMinVal,
348                                      myTimeMaxVal);
349     break;
350   case VISU::TSTREAMLINES: // Stream Lines
351     GeneratePresentations<StreamLines_i>(myStudy,
352                                          aData,
353                                          aResult,
354                                          isRangeDefined(),
355                                          myTimeMinVal,
356                                          myTimeMaxVal);
357     break;
358   case VISU::TGAUSSPOINTS: // Gauss Points
359     GeneratePresentations<GaussPoints_i>(myStudy,
360                                          aData,
361                                          aResult,
362                                          isRangeDefined(),
363                                          myTimeMinVal,
364                                          myTimeMaxVal);
365     break;
366   case VISU::TSCALARMAPONDEFORMEDSHAPE: // Scalar map on deformed shape
367     GeneratePresentations<ScalarMapOnDeformedShape_i>(myStudy,
368                                                       aData,
369                                                       aResult,
370                                                       isRangeDefined(),
371                                                       myTimeMinVal,
372                                                       myTimeMaxVal);
373     break;
374   default:
375     MESSAGE("Not implemented for this presentation type: " << aData.myPrsType);
376     return;
377   }
378 }
379
380
381 //------------------------------------------------------------------------
382 CORBA::Boolean VISU_TimeAnimation::generateFrames() {
383   if (!myView) {
384     MESSAGE("Viewer is not defined for animation");
385     return false;
386   }
387
388   myLastError = QString("Frame(s) for ");
389   bool aNoError = true;
390
391   clearView();
392
393   for (int i = 0; i < getNbFields(); i++) {
394     FieldData& aData = myFieldsLst[i];
395     aData.myActors.resize(aData.myNbFrames,NULL);
396     for (long j = 0; j < aData.myNbFrames; j++) {
397       VISU_Actor* aActor = NULL;
398       try{
399         aData.myPrs[j]->SetOffset(aData.myOffset);
400         aActor = aData.myPrs[j]->CreateActor();
401         myView->AddActor(aActor);
402         if(j == 0)
403           aActor->VisibilityOn();
404         else
405           aActor->VisibilityOff();
406       }catch(...){ //catch(std::runtime_error& exc){
407         aNoError = false;
408         myLastError += QString("%1 ").arg(aData.myTiming[j]);
409       }
410       aData.myActors[j] = aActor;
411     }
412   }
413   myFrame = 0;
414   myLastError += QString(" timestamp(s) cannot be created.");
415   emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
416   myView->Repaint();
417   return aNoError;
418 }
419
420 //------------------------------------------------------------------------
421 void VISU_TimeAnimation::clearView() {
422   if (!myView) {
423     MESSAGE("Viewer is not defined for animation");
424     return;
425   }
426   vtkRenderer* aRen = myView->getRenderer();
427   for (int i = 0; i < getNbFields(); i++) {
428     FieldData& aData = myFieldsLst[i];
429     if (!aData.myActors.empty()) {
430       for (int i = 0, iEnd = aData.myActors.size(); i < iEnd; i++) {
431         if (aData.myActors[i] != 0) {
432           aData.myActors[i]->RemoveFromRender(aRen);
433         }
434       }
435       aData.myActors.clear();
436     }
437   }
438   VISU::RepaintView(myView);
439 }
440
441 //------------------------------------------------------------------------
442 void VISU_TimeAnimation::stopAnimation() {
443   myIsActive = false;
444 }
445
446 //------------------------------------------------------------------------
447 void VISU_TimeAnimation::startAnimation() {
448   if (!myIsActive) {
449     myIsActive = true;
450     QThread::start();
451   }
452 }
453
454 //------------------------------------------------------------------------
455 void VISU_TimeAnimation::nextFrame() {
456   if (!myView) {
457     MESSAGE("Viewer is not defined for animation");
458     return;
459   }
460   stopAnimation();
461   if (myFrame < (myFieldsLst[0].myNbFrames-1)) {
462     int i;
463     for (i = 0; i < getNbFields(); i++)
464       if (myFieldsLst[i].myActors[myFrame] != 0)
465         myFieldsLst[i].myActors[myFrame]->VisibilityOff();
466
467     myFrame++;
468     for (i = 0; i < getNbFields(); i++)
469       if (myFieldsLst[i].myActors[myFrame] != 0)
470         myFieldsLst[i].myActors[myFrame]->VisibilityOn();
471
472     emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
473     myView->Repaint();
474   }
475 }
476
477 //------------------------------------------------------------------------
478 void VISU_TimeAnimation::prevFrame() {
479   if (!myView) {
480     MESSAGE("Viewer is not defined for animation");
481     return;
482   }
483   stopAnimation();
484   if (myFrame > 0) {
485     int i;
486     for (i = 0; i < getNbFields(); i++)
487       if (myFieldsLst[i].myActors[myFrame] != 0)
488         myFieldsLst[i].myActors[myFrame]->VisibilityOff();
489
490     myFrame--;
491     for (i = 0; i < getNbFields(); i++)
492       if (myFieldsLst[i].myActors[myFrame] != 0)
493         myFieldsLst[i].myActors[myFrame]->VisibilityOn();
494
495     emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
496     myView->Repaint();
497   }
498 }
499
500 //------------------------------------------------------------------------
501 void VISU_TimeAnimation::firstFrame() {
502   if (!myView) {
503     MESSAGE("Viewer is not defined for animation");
504     return;
505   }
506   stopAnimation();
507   int i;
508   for (i = 0; i < getNbFields(); i++)
509     if(!myFieldsLst[i].myActors.empty())
510       if (myFieldsLst[i].myActors[myFrame] != 0)
511         myFieldsLst[i].myActors[myFrame]->VisibilityOff();
512   myFrame = 0;
513   for (i = 0; i < getNbFields(); i++)
514     if(!myFieldsLst[i].myActors.empty())
515       if (myFieldsLst[i].myActors[myFrame] != 0)
516         myFieldsLst[i].myActors[myFrame]->VisibilityOn();
517   if(!myFieldsLst[0].myTiming.empty()){
518     emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
519     myView->Repaint();
520   }
521 }
522
523 //------------------------------------------------------------------------
524 void VISU_TimeAnimation::lastFrame() {
525   if (!myView) {
526     MESSAGE("Viewer is not defined for animation");
527     return;
528   }
529   stopAnimation();
530   int i;
531   for (i = 0; i < getNbFields(); i++)
532    if (myFieldsLst[i].myActors[myFrame] != 0)
533       myFieldsLst[i].myActors[myFrame]->VisibilityOff();
534
535   myFrame = myFieldsLst[0].myNbFrames-1;
536   for (i = 0; i < getNbFields(); i++)
537     if (myFieldsLst[i].myActors[myFrame] != 0)
538       myFieldsLst[i].myActors[myFrame]->VisibilityOn();
539
540   emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
541   myView->Repaint();
542 }
543
544
545 //------------------------------------------------------------------------
546 // For Batchmode using
547 void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame) {
548   if (!myView) {
549     MESSAGE("Viewer is not defined for animation");
550     return;
551   }
552   if ((theFrame < 0) || (theFrame > (getNbFrames()-1)))
553     return;
554   stopAnimation();
555   qApp->lock();
556   qApp->syncX();
557   int i;
558   for (i = 0; i < getNbFields(); i++)
559     if (myFieldsLst[i].myActors[myFrame] != 0)
560       myFieldsLst[i].myActors[myFrame]->VisibilityOff();
561
562   myFrame = theFrame;
563   for (i = 0; i < getNbFields(); i++)
564     if (myFieldsLst[i].myActors[myFrame] != 0)
565       myFieldsLst[i].myActors[myFrame]->VisibilityOn();
566
567   emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
568   myView->Repaint();
569   qApp->flushX();
570   qApp->processEvents(3);
571   qApp->unlock();
572 }
573
574
575 //------------------------------------------------------------------------
576 VISU::ColoredPrs3d_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField, CORBA::Long theFrame) {
577   if ((theField > getNbFields()) || (theField < 0))
578     return VISU::ColoredPrs3d::_nil();
579   if ((theFrame < 0) || (theFrame > (myFieldsLst[theField].myNbFrames - 1)))
580     return VISU::ColoredPrs3d::_nil();
581   return myFieldsLst[theField].myPrs[theFrame]->_this();
582 }
583
584
585 //------------------------------------------------------------------------
586 CORBA::Long VISU_TimeAnimation::getNbFrames() {
587   return (getNbFields() > 0)? myFieldsLst[0].myNbFrames : 0;
588 }
589
590
591 //------------------------------------------------------------------------
592 void VISU_TimeAnimation::run()
593 {
594   if (!myView) {
595     MESSAGE("Viewer is not defined for animation");
596     return;
597   }
598   double k = 1;
599   bool   isDumping = !myDumpPath.isEmpty();
600   double aOneVal = 1;
601   if (myFieldsLst[0].myNbFrames > 2)
602     aOneVal = myFieldsLst[0].myTiming[1] - myFieldsLst[0].myTiming[0];
603   myFileIndex = 0;
604   int aNbFiles = 0;
605   QValueList<int> anIndexList;
606
607   qApp->lock();
608   while (myIsActive) {
609     emit frameChanged(myFrame, myFieldsLst[0].myTiming[myFrame]);
610     if(!(myFieldsLst[0].myField))
611       break;
612     for (int i = 0; i < getNbFields(); i++) {
613       FieldData& aData = myFieldsLst[i];
614       if (myFrame > 0) {
615         if (aData.myActors[myFrame-1] != 0)
616           aData.myActors[myFrame-1]->VisibilityOff();
617       } else {
618         if (aData.myActors[aData.myNbFrames-1] != 0)
619           aData.myActors[aData.myNbFrames-1]->VisibilityOff();
620       }
621       if (aData.myActors[myFrame] != 0) {
622         aData.myActors[myFrame]->VisibilityOn();
623       }
624     }
625     myView->Repaint(false);
626
627     k = 1;
628     if (myProportional) {
629       switch (myFrame) {
630       case 0:
631         break;
632       case 1:
633         if (myFieldsLst[0].myNbFrames > 2)
634           k = (myFieldsLst[0].myTiming[myFrame+1] -
635                myFieldsLst[0].myTiming[myFrame]) / aOneVal;
636         break;
637       default:
638         if (myFrame < (myFieldsLst[0].myNbFrames - 1))
639           k = (myFieldsLst[0].myTiming[myFrame+1] -
640                myFieldsLst[0].myTiming[myFrame]) / aOneVal;
641       }
642     }
643     int delay = (int)(1000. * k / mySpeed);
644     isDumping = !myDumpPath.isEmpty();
645     if (delay < 1 && isDumping) {
646       // We must unlock mutex for some time before grabbing to allow view updating
647       delay = 1;
648     }
649     qApp->unlock();
650     msleep(delay);
651     qApp->lock();
652
653     if (isDumping) {
654       // We must unlock mutex for some time before grabbing to allow view updating
655       qApp->unlock();
656       msleep(delay);
657       qApp->lock();
658       if(!(myFieldsLst[0].myField)) // break, if field was deleted.
659         break;
660       if (myDumpFormat.compare("AVI") != 0) {
661         QString aFile(myDumpPath);
662         QString aName = QString("%1").arg(myFieldsLst[0].myTiming[myFrame]);
663         int aPos = -1;
664         while ((aPos = aName.find(".")) > -1 )
665           aName.replace(aPos, 1, "_");
666         aFile += aName;
667         aFile += ".";
668         aFile += myDumpFormat.lower();
669         myView->dumpViewToFormat(aFile,myDumpFormat);
670       } else {
671         QFileInfo aFileInfo(myDumpPath);
672         QString aDirPath = aFileInfo.dirPath(true);
673         QString aBaseName = aFileInfo.fileName();
674
675         switch (myFrame) {
676         case 0: 
677           break;
678         case 1:
679           myFileIndex += 5;
680           break;
681         default:
682           if (myProportional) {
683             double p = (myFieldsLst[0].myTiming[myFrame] -
684                         myFieldsLst[0].myTiming[myFrame-1]) / aOneVal;
685             myFileIndex += (long) (5*p);
686           } else {
687             myFileIndex += 5;
688           }
689         }
690
691         QString aFile = aDirPath + QDir::separator() + aBaseName;
692         aFile += "_";
693         aFile += QString("%1").arg(myFileIndex).rightJustify(8, '0');
694         aFile += ".jpeg";
695
696         /* check image size is divisable 16
697         myView->dumpViewToFormat(aFile,"JPEG");
698         */
699         SUIT_ViewWindow* aView = myView;
700         QImage img = aView->dumpView();
701         if (!img.isNull()) {
702           int width = img.width(); width = (width/16)*16;
703           int height = img.height(); height = (height/16)*16;
704           QImage copy = img.copy(0, 0, width, height);
705           if (copy.save(aFile, "JPEG")) {
706             anIndexList.append(myFileIndex);
707             aNbFiles++;
708           }
709         }
710       }
711     }
712
713     if (!myIsActive) break;
714
715     myFrame++;
716     if (myFrame == myFieldsLst[0].myNbFrames) {
717       if (!myCycling) {
718         myIsActive = false;
719         myFrame--;
720         break;
721       } else
722         myFrame = 0;
723     }
724   }
725
726   // make AVI file if need
727   if (isDumping && myDumpFormat.compare("AVI") == 0) {
728     double aFPS = 17.3 * mySpeed;
729
730     QFileInfo aFileInfo(myDumpPath);
731     QString aDirPath = aFileInfo.dirPath(true);
732     QString aBaseName = aFileInfo.fileName();
733
734     // add missing files
735     if (anIndexList.count() > 1) {
736       QString aFFile = aDirPath + QDir::separator() + aBaseName;
737       aFFile += QString("_%1.jpeg");
738       int aStartIndex = anIndexList[0], anEndIndex;
739       for (int i = 1; i < anIndexList.count(); i++) {
740         anEndIndex = anIndexList[i];
741         QString aCurFile = aFFile.arg(QString::number(aStartIndex).rightJustify(8, '0'));
742         QStringList aCommands;
743         for (int j = aStartIndex+1; j < anEndIndex; j++) {
744           QString aFile = aFFile.arg(QString::number(j).rightJustify(8, '0'));
745           aCommands.append(QString("ln -s %1 %2").arg(aCurFile).arg(aFile));
746         }
747         system(aCommands.join(" ; \\\n").latin1());
748         aStartIndex = anEndIndex;
749       }
750     }
751
752     // make AVI file
753     QString aPattern = aDirPath + QDir::separator() + aBaseName;
754     aPattern += "_\%08d.jpeg";
755
756     QString aCmd = myAVIMaker;
757     aCmd += " -I p";
758     aCmd += " -v 0";
759     aCmd += QString(" -f %1").arg(aFPS);
760     // aCmd += QString(" -n %1").arg(aNbFiles);
761     aCmd += QString(" -n %1").arg(myFileIndex+1);
762     aCmd += QString(" -j %1").arg(aPattern);
763     aCmd += " | yuv2lav";
764     aCmd += QString(" -o %1").arg(myDumpPath);
765     system(aCmd.latin1());
766
767     // remove temporary jpeg files
768     aCmd = "( ";
769     aCmd += QString("cd %1").arg(aDirPath);
770     aCmd += "; ls";
771     aCmd += QString(" | egrep '%1_[0-9]*.jpeg'").arg(aBaseName);
772     aCmd += " | xargs rm";
773     aCmd += " )";
774     system(aCmd.latin1());
775   }
776
777   emit stopped();
778   qApp->unlock();
779   QThread::exit();
780 }
781
782 //------------------------------------------------------------------------
783 VISU::Result_i* VISU_TimeAnimation::createPresent (_PTR(SObject) theField)
784 {
785   _PTR(SObject) aSObj = theField->GetFather();
786   aSObj = aSObj->GetFather();
787   aSObj = aSObj->GetFather();
788   CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj);
789   if (CORBA::is_nil(anObject)) return NULL;
790   return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
791 }
792
793 //------------------------------------------------------------------------
794 VISU::Storable::TRestoringMap VISU_TimeAnimation::getMapOfValue (_PTR(SObject) theSObject)
795 {
796   VISU::Storable::TRestoringMap aMap;
797   if (theSObject) {
798     _PTR(GenericAttribute) anAttr;
799     if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
800       _PTR(AttributeComment) aComment (anAttr);
801       std::string aString = aComment->Value();
802       QString strIn (aString.c_str());
803       VISU::Storable::StrToMap(strIn, aMap);
804     }
805   }
806   return aMap;
807 }
808
809 //------------------------------------------------------------------------
810 double VISU_TimeAnimation::getTimeValue (_PTR(SObject) theTimeStamp)
811 {
812   _PTR(GenericAttribute) anAttr;
813   if (theTimeStamp->FindAttribute(anAttr, "AttributeName")) {
814     _PTR(AttributeName) aName (anAttr);
815     QString aNameString (aName->Value().c_str());
816     int time_len = aNameString.find(',');
817     if (time_len > -1)
818       return aNameString.left(time_len).toDouble();
819     else
820       return aNameString.toDouble();
821   }
822   return -1.0;
823 }
824
825 //------------------------------------------------------------------------
826 void VISU_TimeAnimation::setSpeed(CORBA::Long theSpeed)
827 {
828   mySpeed = (theSpeed<1)? 1 : theSpeed;
829 }
830
831 std::string VISU_TimeAnimation::setDumpFormat(const char* theFormat)
832 {
833   myDumpFormat = theFormat;
834   QStrList aDumpFormats = QImageIO::outputFormats();
835   if (myDumpFormat.isEmpty() || 
836       (aDumpFormats.find(theFormat) < 0 && myDumpFormat.compare("AVI") != 0)) {
837     if (aDumpFormats.find("JPEG"))
838       myDumpFormat = "JPEG";
839     else
840       myDumpFormat = aDumpFormats.at(0);
841   }
842   return myDumpFormat.latin1();
843 }
844
845 //------------------------------------------------------------------------
846 bool VISU_TimeAnimation::checkAVIMaker() const
847 {
848   QStrList aDumpFormats = QImageIO::outputFormats();
849   if (aDumpFormats.find("JPEG") < 0) return false;
850
851   QString aCmd("which ");
852   aCmd += myAVIMaker;
853   aCmd += " >& /dev/null";
854   int iErr = system(aCmd.latin1());
855   return (iErr == 0);
856 }
857
858 //************************************************************************
859 int VISU_TimeAnimation::myNBAnimations = 0;
860 QString VISU_TimeAnimation::GenerateName()
861 {
862   return VISU::GenerateName("Animation", myNBAnimations++);
863 }
864
865 //------------------------------------------------------------------------
866 std::string GetPresentationComment (VISU::VISUType thePrsType)
867 {
868   std::string aPrsCmt;
869   switch (thePrsType) {
870   case VISU::TSCALARMAP:
871     aPrsCmt = VISU::ScalarMap_i::myComment;
872     break;
873   case VISU::TISOSURFACE:
874     aPrsCmt = VISU::IsoSurfaces_i::myComment;
875     break;
876   case VISU::TCUTPLANES:
877     aPrsCmt = VISU::CutPlanes_i::myComment;
878     break;
879   case VISU::TCUTLINES:
880     aPrsCmt = VISU::CutLines_i::myComment;
881     break;
882   case VISU::TPLOT3D:
883     aPrsCmt = VISU::Plot3D_i::myComment;
884     break;
885   case VISU::TDEFORMEDSHAPE:
886     aPrsCmt = VISU::DeformedShape_i::myComment;
887     break;
888   case VISU::TVECTORS:
889     aPrsCmt = VISU::Vectors_i::myComment;
890     break;
891   case VISU::TSTREAMLINES:
892     aPrsCmt = VISU::StreamLines_i::myComment;
893     break;
894   case VISU::TGAUSSPOINTS:
895     aPrsCmt = VISU::GaussPoints_i::myComment;
896     break;
897   case VISU::TSCALARMAPONDEFORMEDSHAPE:
898     aPrsCmt = VISU::ScalarMapOnDeformedShape_i::myComment;
899     break;
900   default:
901     aPrsCmt = "Unknown presentation";
902     break;
903   }
904   return aPrsCmt;
905 }
906
907 //------------------------------------------------------------------------
908 SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
909 {
910   if (myStudy->GetProperties()->IsLocked())
911     return SALOMEDS::SObject::_nil();
912
913   _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
914   aStudyBuilder->NewCommand();  // There is a transaction
915   _PTR(SComponent) aSComponent = VISU::ClientFindOrCreateVisuComponent(myStudy);
916   std::string aSComponentEntry = aSComponent->GetID();
917
918   QString aComment;
919   aComment.sprintf("myComment=ANIMATION;myType=%d;myTimeMinVal=%g;myTimeMaxVal=%g",
920                    VISU::TANIMATION,myTimeMinVal,myTimeMaxVal);
921
922   string anEntry = VISU::CreateAttributes(myStudy,aSComponentEntry.c_str(),"","",
923                                           GenerateName(),"",aComment,true);
924   myAnimEntry = anEntry.c_str();
925   _PTR(SObject) aAnimSObject = myStudy->FindObjectID(anEntry.c_str());
926
927   for (int i = 0; i < getNbFields(); i++) {
928     FieldData& aData = myFieldsLst[i];
929
930     _PTR(SObject) newObj = aStudyBuilder->NewObject(aAnimSObject);
931     aStudyBuilder->Addreference(newObj, aData.myField);
932
933     if (aData.myPrs.empty()) {
934       generatePresentations(i);
935     }
936     ostringstream strOut;
937     aData.myPrs[0]->ToStream(strOut);
938     string aPrsComment = strOut.str();
939     VISU::CreateAttributes(myStudy, newObj->GetID().c_str(),"","",
940                            aData.myPrs[0]->GetComment(),"",aPrsComment.c_str(),true);
941   }
942   aStudyBuilder->CommitCommand();
943
944   return VISU::GetSObject(aAnimSObject);
945 }
946
947 //------------------------------------------------------------------------
948 void VISU_TimeAnimation::saveAnimation()
949 {
950   if (myStudy->GetProperties()->IsLocked()) return;
951   if (myAnimEntry.isEmpty()) return;
952
953   _PTR(SObject) aAnimSObject = myStudy->FindObjectID(myAnimEntry.latin1());
954   if (!aAnimSObject) return;
955
956   _PTR(StudyBuilder) aStudyBuilder = myStudy->NewBuilder();
957   aStudyBuilder->NewCommand();  // There is a transaction
958   _PTR(SComponent) aSComponent = VISU::ClientFindOrCreateVisuComponent(myStudy);
959   std::string aSComponentEntry = aSComponent->GetID();
960
961   QString aComment;
962   aComment.sprintf("myComment=ANIMATION;myType=%d;myTimeMinVal=%g;myTimeMaxVal=%g",
963                    VISU::TANIMATION,myTimeMinVal,myTimeMaxVal);
964
965   _PTR(GenericAttribute) anAttr;
966   anAttr = aStudyBuilder->FindOrCreateAttribute(aAnimSObject, "AttributeComment");
967   _PTR(AttributeComment) aCmnt (anAttr);
968   aCmnt->SetValue(aComment.latin1());
969
970   _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
971   int i = 0, nbf = getNbFields();
972   for (anIter->Init(); anIter->More(); anIter->Next(), i++) {
973     if (i >= nbf) break; // it must not be
974     FieldData& aData = myFieldsLst[i];
975
976     // Get presentation name and comment
977     if (aData.myPrs.empty()) {
978       generatePresentations(i);
979     }
980     ostringstream strOut;
981     aData.myPrs[0]->ToStream(strOut);
982     string aPrsComment = strOut.str();
983     string aPrsNameTxt = aData.myPrs[0]->GetComment();
984
985     // Save in study
986     _PTR(SObject) aRefObj = anIter->Value();
987     _PTR(ChildIterator) anPrsIter = myStudy->NewChildIterator(aRefObj);
988     anPrsIter->Init();
989
990     if (anPrsIter->More()) {
991       _PTR(SObject) aPrsObj = anPrsIter->Value();
992       anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeComment");
993       aCmnt = _PTR(AttributeComment)(anAttr);
994       aCmnt->SetValue(aPrsComment.c_str());
995
996       anAttr = aStudyBuilder->FindOrCreateAttribute(aPrsObj, "AttributeName");
997       _PTR(AttributeName) aPrsName (anAttr);
998       aPrsName->SetValue(aPrsNameTxt);
999
1000     } else {
1001       VISU::CreateAttributes(myStudy, aRefObj->GetID().c_str(),"","",
1002                              aPrsNameTxt.c_str(),"",aPrsComment.c_str(),true);
1003     }
1004   }
1005   aStudyBuilder->CommitCommand();
1006 }
1007
1008 //------------------------------------------------------------------------
1009 void VISU_TimeAnimation::restoreFromStudy(SALOMEDS::SObject_ptr theField)
1010 {
1011   _PTR(SObject) aAnimSObject = VISU::GetClientSObject(theField, myStudy);
1012   restoreFromStudy(aAnimSObject);
1013 }
1014
1015 void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
1016 {
1017   _PTR(SObject) aAnimSObject = theField;
1018
1019   VISU::Storable::TRestoringMap aMap;
1020   _PTR(GenericAttribute) anAttr;
1021   if (!aAnimSObject->FindAttribute(anAttr, "AttributeComment")) return;
1022
1023   _PTR(AttributeComment) aComment (anAttr);
1024   string aComm = aComment->Value();
1025   QString strIn (aComm.c_str());
1026   VISU::Storable::StrToMap(strIn,aMap);
1027   bool isExist;
1028
1029   myTimeMinVal = VISU::Storable::FindValue(aMap,"myTimeMinVal",&isExist).toDouble();
1030   myTimeMaxVal = VISU::Storable::FindValue(aMap,"myTimeMaxVal",&isExist).toDouble();
1031
1032   _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
1033   for (anIter->Init(); anIter->More(); anIter->Next()) {
1034     _PTR(SObject) aRefObj = anIter->Value();
1035     _PTR(SObject) aFieldObj;
1036     if (!aRefObj->ReferencedObject(aFieldObj) ) continue;
1037     addField(aFieldObj);
1038     FieldData& aData = getFieldData(getNbFields()-1);
1039
1040     // Get Presentation object
1041     _PTR(ChildIterator) anPrsIter = myStudy->NewChildIterator(aRefObj);
1042     anPrsIter->Init();
1043     if (!anPrsIter->More()) continue;
1044     _PTR(SObject) aPrsObj = anPrsIter->Value();
1045     if (!aPrsObj->FindAttribute(anAttr, "AttributeName")) continue;
1046     _PTR(AttributeName) aName (anAttr);
1047     string aStr = aName->Value();
1048     QString strName (aStr.c_str());
1049
1050     if (strName == VISU::ScalarMap_i::myComment.c_str())
1051       aData.myPrsType = VISU::TSCALARMAP;
1052     else if (strName == VISU::IsoSurfaces_i::myComment.c_str())
1053       aData.myPrsType = VISU::TISOSURFACE;
1054     else if (strName == VISU::CutPlanes_i::myComment.c_str())
1055       aData.myPrsType = VISU::TCUTPLANES;
1056     else if (strName == VISU::CutLines_i::myComment.c_str())
1057       aData.myPrsType = VISU::TCUTLINES;
1058     else if (strName == VISU::Plot3D_i::myComment.c_str())
1059       aData.myPrsType = VISU::TPLOT3D;
1060     else if (strName == VISU::DeformedShape_i::myComment.c_str())
1061       aData.myPrsType = VISU::TDEFORMEDSHAPE;
1062     else if (strName == VISU::Vectors_i::myComment.c_str())
1063       aData.myPrsType = VISU::TVECTORS;
1064     else if (strName == VISU::StreamLines_i::myComment.c_str())
1065       aData.myPrsType = VISU::TSTREAMLINES;
1066     else if (strName == VISU::GaussPoints_i::myComment.c_str())
1067       aData.myPrsType = VISU::TGAUSSPOINTS;
1068     else if (strName == VISU::ScalarMapOnDeformedShape_i::myComment.c_str())
1069       aData.myPrsType = VISU::TSCALARMAPONDEFORMEDSHAPE;
1070     else
1071       continue;
1072     generatePresentations(getNbFields()-1);
1073
1074     if (!aPrsObj->FindAttribute(anAttr, "AttributeComment")) continue;
1075     _PTR(AttributeComment) aPrsComment (anAttr);
1076     string aPrsComm = aPrsComment->Value();
1077     if (aPrsComm.length() > 0) {
1078       QString strPrsIn (aPrsComm.c_str());
1079       VISU::Storable::TRestoringMap aPrsMap;
1080       VISU::Storable::StrToMap(strPrsIn,aPrsMap);
1081
1082       aData.myPrs[0]->Restore(aPrsMap);
1083     }
1084     aData.myPrs[0]->GetOffset(aData.myOffset);
1085     for (int i = 1; i < aData.myNbFrames; i++) {
1086       //jfa 03.08.2005:aData.myPrs[i]->SameAs(aData.myPrs[0]);
1087       aData.myPrs[i]->SameAsParams(aData.myPrs[0]);//jfa 03.08.2005
1088     }
1089   }
1090   string aStr = aAnimSObject->GetID();
1091   myAnimEntry = aStr.c_str();
1092 }
1093
1094 void VISU_TimeAnimation::onViewDeleted()
1095 {
1096   myView = 0;
1097 }
1098
1099
1100 //========================================================================
1101 //========================================================================
1102 //========================================================================
1103 struct TNewAnimationEvent: public SALOME_Event
1104 {
1105   std::string myStudyName;
1106   VISU::View3D_ptr myView3D;
1107
1108   typedef VISU_TimeAnimation* TResult;
1109   TResult myResult;
1110
1111   TNewAnimationEvent (std::string theStudyName, VISU::View3D_ptr theView3D):
1112     myStudyName(theStudyName),
1113     myView3D(VISU::View3D::_duplicate(theView3D)),
1114     myResult(NULL)
1115   {}
1116
1117   virtual
1118   void
1119   Execute()
1120   {
1121     SUIT_Session* aSession = SUIT_Session::session();
1122     QPtrList<SUIT_Application> anApplications = aSession->applications();
1123     QPtrListIterator<SUIT_Application> anIter (anApplications);
1124     while (SUIT_Application* anApp = anIter.current()) {
1125       ++anIter;
1126       if (SUIT_Study* aSStudy = anApp->activeStudy()) {
1127         if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
1128           if (_PTR(Study) aCStudy = aStudy->studyDS()) {
1129             if (myStudyName == aCStudy->Name()) {
1130               myResult = new VISU_TimeAnimation (aCStudy, myView3D);
1131               break;
1132             }
1133           }
1134         }
1135       }
1136     }
1137   }
1138 };
1139
1140 VISU_TimeAnimation_i::VISU_TimeAnimation_i (SALOMEDS::Study_ptr theStudy,
1141                                             VISU::View3D_ptr theView3D)
1142 {
1143   std::string aStudyName = theStudy->Name();
1144   myAnim = ProcessEvent(new TNewAnimationEvent (aStudyName, theView3D));
1145 }
1146
1147 VISU_TimeAnimation_i::~VISU_TimeAnimation_i()
1148 {
1149   delete myAnim;
1150 }
1151
1152 void VISU_TimeAnimation_i::addField (SALOMEDS::SObject_ptr theField)
1153 {
1154   myAnim->addField(theField);
1155 }
1156
1157 CORBA::Boolean VISU_TimeAnimation_i::generateFrames()
1158 {
1159   return ProcessEvent(new TMemFunEvent<VISU_TimeAnimation,bool>
1160                       (myAnim,&VISU_TimeAnimation::generateFrames));
1161 }
1162
1163 void VISU_TimeAnimation_i::generatePresentations (CORBA::Long theFieldNum)
1164 {
1165   myAnim->generatePresentations(theFieldNum);
1166 }
1167
1168 void VISU_TimeAnimation_i::clearView()
1169 {
1170   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
1171                    (myAnim,&VISU_TimeAnimation::clearView));
1172 }
1173
1174 void VISU_TimeAnimation_i::stopAnimation()
1175 {
1176   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
1177                    (myAnim,&VISU_TimeAnimation::stopAnimation));
1178 }
1179
1180 void VISU_TimeAnimation_i::startAnimation()
1181 {
1182   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
1183                    (myAnim,&VISU_TimeAnimation::startAnimation));
1184 }
1185
1186 void VISU_TimeAnimation_i::nextFrame()
1187 {
1188   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
1189                    (myAnim,&VISU_TimeAnimation::nextFrame));
1190 }
1191
1192 void VISU_TimeAnimation_i::prevFrame()
1193 {
1194   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
1195                    (myAnim,&VISU_TimeAnimation::prevFrame));
1196 }
1197
1198 void VISU_TimeAnimation_i::firstFrame()
1199 {
1200   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
1201                    (myAnim,&VISU_TimeAnimation::firstFrame));
1202 }
1203
1204 void VISU_TimeAnimation_i::lastFrame()
1205 {
1206   ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>
1207                    (myAnim,&VISU_TimeAnimation::lastFrame));
1208 }
1209
1210 void VISU_TimeAnimation_i::gotoFrame(CORBA::Long theFrame)
1211 {
1212   ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,CORBA::Long>
1213                    (myAnim,&VISU_TimeAnimation::gotoFrame,theFrame));
1214 }
1215
1216 CORBA::Long VISU_TimeAnimation_i::getNbFields()
1217 {
1218   return myAnim->getNbFields();
1219 }
1220
1221 CORBA::Long VISU_TimeAnimation_i::getNbFrames()
1222 {
1223   return myAnim->getNbFrames();
1224 }
1225
1226 CORBA::Boolean VISU_TimeAnimation_i::isRunning()
1227 {
1228   return myAnim->isRunning();
1229 }
1230
1231 CORBA::Long VISU_TimeAnimation_i::getCurrentFrame()
1232 {
1233   return myAnim->getCurrentFrame();
1234 }
1235
1236 VISU::ColoredPrs3d_ptr VISU_TimeAnimation_i::getPresentation
1237                     (CORBA::Long theField, CORBA::Long theFrame)
1238 {
1239   return myAnim->getPresentation(theField,theFrame);
1240 }
1241
1242 void VISU_TimeAnimation_i::setPresentationType (CORBA::Long theFieldNum,
1243                                                 VISU::VISUType theType)
1244 {
1245   myAnim->setPresentationType(theFieldNum,theType);
1246 }
1247
1248 VISU::VISUType VISU_TimeAnimation_i::getPresentationType (CORBA::Long theFieldNum)
1249 {
1250   return myAnim->getPresentationType(theFieldNum);
1251 }
1252
1253 void VISU_TimeAnimation_i::setSpeed(CORBA::Long theSpeed)
1254 {
1255   myAnim->setSpeed(theSpeed);
1256 }
1257
1258 CORBA::Long VISU_TimeAnimation_i::getSpeed()
1259 {
1260   return myAnim->getSpeed();
1261 }
1262
1263 CORBA::Boolean VISU_TimeAnimation_i::isProportional()
1264 {
1265   return myAnim->isProportional();
1266 }
1267
1268 void VISU_TimeAnimation_i::setAnimationRange (CORBA::Double theMin,
1269                                               CORBA::Double theMax)
1270 {
1271   myAnim->setAnimationRange(theMin,theMax);
1272 }
1273
1274 CORBA::Double VISU_TimeAnimation_i::getMinRange()
1275 {
1276   return myAnim->getMinRange();
1277 }
1278
1279 CORBA::Double VISU_TimeAnimation_i::getMaxRange()
1280 {
1281   return myAnim->getMaxRange();
1282 }
1283
1284 CORBA::Boolean VISU_TimeAnimation_i::isRangeDefined()
1285 {
1286   return myAnim->isRangeDefined();
1287 }
1288
1289 void VISU_TimeAnimation_i::dumpTo (const char* thePath)
1290 {
1291   myAnim->dumpTo(thePath);
1292 }
1293
1294 char* VISU_TimeAnimation_i::setDumpFormat (const char* theFormat)
1295 {
1296   string aDumpFormat = myAnim->setDumpFormat(theFormat);
1297   return CORBA::string_dup(aDumpFormat.c_str());
1298 }
1299
1300 CORBA::Boolean VISU_TimeAnimation_i::isCycling()
1301 {
1302   return myAnim->isCycling();
1303 }
1304
1305 CORBA::Double VISU_TimeAnimation_i::getMinTime()
1306 {
1307   return myAnim->getMinTime();
1308 }
1309
1310 CORBA::Double VISU_TimeAnimation_i::getMaxTime()
1311 {
1312   return myAnim->getMaxTime();
1313 }
1314
1315 void VISU_TimeAnimation_i::setProportional (CORBA::Boolean theProp)
1316 {
1317   myAnim->setProportional(theProp);
1318 }
1319
1320 void VISU_TimeAnimation_i::setCycling (CORBA::Boolean theCycle)
1321 {
1322   myAnim->setCycling(theCycle);
1323 }
1324
1325 SALOMEDS::SObject_ptr VISU_TimeAnimation_i::publishInStudy()
1326 {
1327   return myAnim->publishInStudy();
1328 }
1329
1330 void VISU_TimeAnimation_i::restoreFromStudy(SALOMEDS::SObject_ptr theObj)
1331 {
1332   myAnim->restoreFromStudy(theObj);
1333 }
1334
1335 CORBA::Boolean VISU_TimeAnimation_i::isSavedInStudy()
1336 {
1337   return myAnim->isSavedInStudy();
1338 }
1339
1340 void VISU_TimeAnimation_i::saveAnimation()
1341 {
1342   myAnim->saveAnimation();
1343 }