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