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