]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_TimeAnimation.cxx
Salome HOME
IPAL20954 problem loading help pages
[modules/visu.git] / src / VISUGUI / VisuGUI_TimeAnimation.cxx
1 //  Copyright (C) 2007-2008  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 //  File   : VisuGUI_TimeAnimation.cxx
23 //  Author : Vitaly SMETANNIKOV
24 //  Module : VISU
25 //
26 #include "VisuGUI_TimeAnimation.h"
27
28 #include "VisuGUI.h"
29 #include "VisuGUI_Tools.h"
30 #include "VisuGUI_ViewTools.h"
31 #include "VisuGUI_ScalarBarDlg.h"
32 #include "VisuGUI_DeformedShapeDlg.h"
33 #include "VisuGUI_CutPlanesDlg.h"
34 #include "VisuGUI_CutLinesDlg.h"
35 #include "VisuGUI_Plot3DDlg.h"
36 #include "VisuGUI_VectorsDlg.h"
37 #include "VisuGUI_IsoSurfacesDlg.h"
38 #include "VisuGUI_StreamLinesDlg.h"
39 #include "VisuGUI_DeformedShapeAndScalarMapDlg.h"
40 #include "VisuGUI_GaussPointsDlg.h"
41
42 #include "VISU_TimeAnimation.h"
43
44 #include "VISU_ScalarMap_i.hh"
45 #include "VISU_IsoSurfaces_i.hh"
46 #include "VISU_DeformedShape_i.hh"
47 #include "VISU_CutPlanes_i.hh"
48 #include "VISU_Plot3D_i.hh"
49 #include "VISU_CutLines_i.hh"
50 #include "VISU_Vectors_i.hh"
51 #include "VISU_StreamLines_i.hh"
52 #include "VISU_DeformedShapeAndScalarMap_i.hh"
53 #include "VISU_GaussPoints_i.hh"
54
55 #include "VISU_ViewManager_i.hh"
56
57 #include "VISU_ScalarBarActor.hxx"
58 #include "VISU_Actor.h"
59
60 #include "SalomeApp_Study.h"
61 #include "LightApp_Application.h"
62
63 #include "SVTK_ViewWindow.h"
64
65 #include "SUIT_OverrideCursor.h"
66 #include "SUIT_MessageBox.h"
67 #include "SUIT_ResourceMgr.h"
68 #include "SUIT_Session.h"
69 #include "SUIT_Desktop.h"
70 #include "SUIT_FileDlg.h"
71
72 #include <vtkRenderer.h>
73 #include <vtkMapper.h>
74
75 #include <QGridLayout>
76 #include <QImage>
77 #include <QImageWriter>
78 #include <QLayout>
79 #include <QSlider>
80 #include <QThread>
81 #include <QListWidget>
82 #include <QLCDNumber>
83 #include <QToolButton>
84 #include <QKeyEvent>
85 #include <QComboBox>
86 #include <QLineEdit>
87 #include <QRadioButton>
88 #include <QGroupBox>
89 #include <QPushButton>
90 #include <QLabel>
91
92 #include <qwt_wheel.h>
93
94 #define  MAXVAL 1e10
95 #define  VALPRECISION 8
96
97 namespace {
98   void GeneratePresentations(int theFieldId, VISU_TimeAnimation* theAnimator)
99   {
100     if(theAnimator->getNbFields() == 0)
101       return;
102
103     theAnimator->generatePresentations(theFieldId);
104     FieldData& aFieldData = theAnimator->getFieldData(theFieldId);
105
106
107     int aRefFieldId = ( theAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) ? theFieldId : 0;
108     if(VISU::ColoredPrs3d_i* aInitialPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(theAnimator->getFieldData(aRefFieldId).myPrs[0])){
109       for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) {
110         VISU::ColoredPrs3d_i* aColoredPrs3d = aFieldData.myPrs[aFrameId];
111
112         // Special case for DeformedShape And ScalarMap presentation
113         // Restore time stamp number for all presentations
114         VISU::DeformedShapeAndScalarMap_i* aDeformedAndScalPrs = dynamic_cast<VISU::DeformedShapeAndScalarMap_i*>(aColoredPrs3d);
115         int aTimeStampNum = -1;
116         if(aDeformedAndScalPrs){
117           aTimeStampNum = aDeformedAndScalPrs->GetScalarTimeStampNumber();
118         }
119         aColoredPrs3d->SameAs(aInitialPrs3d);
120
121         if(aDeformedAndScalPrs){
122           aDeformedAndScalPrs->SetScalarField(aDeformedAndScalPrs->GetScalarEntity(),
123                                               aDeformedAndScalPrs->GetScalarFieldName(),
124                                               aTimeStampNum);
125         }
126
127         std::string aTitle = aColoredPrs3d->GetCTitle();
128         if ( aFrameId != 0 && theAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) {
129           aColoredPrs3d->SetTitle(aTitle.c_str());
130         }
131       }
132     }
133   }
134 }
135
136 ArrangeDlg::ArrangeDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator)
137   : QDialog(theParent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
138     myAnimator(theAnimator),
139     myViewWindow(theAnimator->getViewer())
140 {
141   setModal( true );
142   myCurrent = 0;
143   init();
144   QStringList aFieldNames;
145   // Find names of fields
146   for (int i = 0; i < myAnimator->getNbFields(); i++) {
147     _PTR(SObject) aSObject = myAnimator->getFieldData(i).myField;
148     VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aSObject);
149     aFieldNames.append(aRestoringMap["myName"]);
150     Offset aOffs;
151     aOffs.myOffset[0] = myAnimator->getFieldData(i).myOffset[0];
152     aOffs.myOffset[1] = myAnimator->getFieldData(i).myOffset[1];
153     aOffs.myOffset[2] = myAnimator->getFieldData(i).myOffset[2];
154     myOffsets.append(aOffs);
155   }
156   myFieldLst->addItems(aFieldNames);
157   myFieldLst->setCurrentRow(0);
158 }
159
160 ArrangeDlg::ArrangeDlg(QWidget* theParent,
161                        const SalomeApp_Module* theModule,
162                        SVTK_ViewWindow* theViewWindow)
163   : QDialog(theParent,  Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
164     myAnimator(NULL),
165     myViewWindow(theViewWindow)
166 {
167   setModal( true );
168   myCurrent = 0;
169   init();
170   QStringList aPrsNames;
171   vtkActorCollection *aCollection = myViewWindow->getRenderer()->GetActors();
172   aCollection->InitTraversal();
173   while(vtkActor* anActor = aCollection->GetNextActor()){
174     if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor)) {
175       if(anVISUActor->GetVisibility() != 0){
176         if (VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d()){
177           if(!myPrsMap.contains(aPrs)){
178             Handle(SALOME_InteractiveObject) anIO = aPrs->GetIO();
179             if(!anIO->hasEntry())
180               continue;
181             SalomeApp_Study* aStudy = VISU::GetAppStudy(theModule);
182             VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anIO->getEntry());
183             if(_PTR(SObject) aSObject = anObjectInfo.mySObject){
184               _PTR(GenericAttribute) anAttr;
185               if (aSObject->FindAttribute(anAttr, "AttributeName")) {
186                 _PTR(AttributeName) aName(anAttr);
187                 QString strIn(aName->Value().c_str());
188                 aPrsNames.append(strIn);
189                 myPrsMap[aPrs] = myOffsets.count();
190                 Offset aOffs;
191                 anVISUActor->GetPosition(aOffs.myOffset);
192                 myOffsets.append(aOffs);
193               }
194             }
195           }
196         }
197       }
198     } else { //if PointMap3d Actor
199       if (VISU_ActorBase* anActorBase = dynamic_cast<VISU_ActorBase*>(anActor))
200         if(anActorBase->GetVisibility() != 0)
201           if (VISU::PointMap3d_i* aPrs = dynamic_cast<VISU::PointMap3d_i*>(anActorBase->GetFactory())) {
202             if(!myPointMapPrsMap.contains(aPrs)){
203               Handle(SALOME_InteractiveObject) anIO = aPrs->GetIO();
204               if(!anIO->hasEntry())
205                 continue;
206               SalomeApp_Study* aStudy = VISU::GetAppStudy(theModule);
207               VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anIO->getEntry());
208               if(_PTR(SObject) aSObject = anObjectInfo.mySObject){
209                 _PTR(GenericAttribute) anAttr;
210                 if (aSObject->FindAttribute(anAttr, "AttributeName")) {
211                   _PTR(AttributeName) aName(anAttr);
212                   QString strIn(aName->Value().c_str());
213                   aPrsNames.append(strIn);
214                   myPointMapPrsMap[aPrs] = myOffsets.count();
215                   Offset aOffs;
216                   anActorBase->GetPosition(aOffs.myOffset);
217                   myOffsets.append(aOffs);
218                 }
219               }
220             }
221           }
222     }
223   }
224   myFieldLst->addItems(aPrsNames);
225   myFieldLst->setCurrentRow(0);
226 }
227
228 void ArrangeDlg::init()
229 {
230   setWindowTitle("Arrange Presentations");
231   setSizeGripEnabled( TRUE );
232
233   QVBoxLayout* aMainLayout = new QVBoxLayout(this);
234   aMainLayout->setMargin( 7 );
235   aMainLayout->setSpacing(5);
236
237   QButtonGroup* aBtnGrp = new QButtonGroup( this);
238   aBtnGrp->setExclusive(true);
239   //aMainLayout->addWidget(aBtnGrp);
240
241   QGroupBox* aBtnGB = new QGroupBox( this );
242   QHBoxLayout* aHBLay = new QHBoxLayout( aBtnGB );
243   aMainLayout->addWidget(aBtnGB);
244
245   QRadioButton* aAutoBtn = new QRadioButton("Auto", aBtnGB);
246   aHBLay->addWidget( aAutoBtn );
247   aBtnGrp->addButton(aAutoBtn, AutoMode);
248
249   QRadioButton* aManualBtn = new QRadioButton("Manual", aBtnGB);
250   aHBLay->addWidget( aManualBtn );
251   aBtnGrp->addButton(aManualBtn, ManualMode);
252
253   aAutoBtn->setChecked( true );
254
255   myStackWgt = new QStackedWidget(this);
256   aMainLayout->addWidget(myStackWgt);
257
258   //  AUTO Pane
259   QWidget* aAutoPane = new QWidget(myStackWgt);
260   QVBoxLayout* aAutoLay = new QVBoxLayout( aAutoPane );
261   aAutoLay->setSpacing(5);
262
263   // Axis Group
264   myAxisGrp = new QButtonGroup(aAutoPane);
265
266   QGroupBox* aAxisGB = new QGroupBox( "Axis", aAutoPane );
267   QHBoxLayout* aVBLay = new QHBoxLayout( aAxisGB );
268   aAutoLay->addWidget( aAxisGB );
269
270   QRadioButton* aXBtn = new QRadioButton("X",aAxisGB );
271   aVBLay->addWidget( aXBtn );
272   myAxisGrp->addButton(aXBtn, XAxis);
273
274   QRadioButton* aYBtn = new QRadioButton("Y",aAxisGB );
275   aVBLay->addWidget( aYBtn );
276   myAxisGrp->addButton(aYBtn, YAxis);
277
278   QRadioButton* aZBtn = new QRadioButton("Z",aAxisGB );
279   aVBLay->addWidget( aZBtn );
280   myAxisGrp->addButton(aZBtn, ZAxis);
281
282   aXBtn->setChecked( true );
283
284   //Distance Input
285   QWidget* aDistPane = new QWidget(aAutoPane);
286   QHBoxLayout* aHLay = new QHBoxLayout( aDistPane );
287   aHLay->setSpacing(5);
288   aHLay->addWidget( new QLabel("Relative Distance", aDistPane) );
289   myDistVal = new QtxDoubleSpinBox (-10,10, 0.5, aDistPane);
290   myDistVal->setValue(1);
291   aHLay->addWidget( myDistVal );
292
293   aAutoLay->addWidget( aDistPane );
294
295   myStackWgt->insertWidget( AutoMode, aAutoPane);
296
297   // Manual Pane
298   QWidget* aManualPane = new QWidget(myStackWgt);
299   aHLay = new QHBoxLayout( aManualPane );
300   aHLay->setSpacing(10);
301
302   myFieldLst = new QListWidget(aManualPane);
303   aHLay->addWidget( myFieldLst );
304   connect( myFieldLst, SIGNAL( currentRowChanged(int) ),
305            this, SLOT( onFieldChange(int) ) );
306
307   QWidget* aCoordPane = new QWidget( aManualPane);
308   aHLay->addWidget( aCoordPane );
309   QGridLayout* aCoordLayout = new QGridLayout( aCoordPane );
310   aCoordLayout->setSpacing(5);
311
312   aCoordLayout->addWidget( new QLabel("X", aCoordPane), 0, 0 );
313   myCoord[0] = new QtxDoubleSpinBox(aCoordPane);
314   myCoord[0]->setRange(-MAXVAL, MAXVAL);
315   aCoordLayout->addWidget( myCoord[0], 0, 1 );
316
317   aCoordLayout->addWidget( new QLabel("Y", aCoordPane), 1, 0 );
318   myCoord[1] = new QtxDoubleSpinBox(aCoordPane);
319   myCoord[1]->setRange(-MAXVAL, MAXVAL);
320   aCoordLayout->addWidget( myCoord[1], 1, 1 );
321
322   aCoordLayout->addWidget( new QLabel("Z", aCoordPane), 2, 0 );
323   myCoord[2] = new QtxDoubleSpinBox(aCoordPane);
324   myCoord[2]->setRange(-MAXVAL, MAXVAL);
325   aCoordLayout->addWidget( myCoord[2], 2, 1 );
326
327   myStackWgt->insertWidget(ManualMode, aManualPane );
328
329   myStackWgt->setCurrentIndex(AutoMode);
330
331   connect(aBtnGrp, SIGNAL(buttonClicked(int)), myStackWgt, SLOT(setCurrentIndex(int)) );
332
333   SUIT_Study* aSUITStudy = myViewWindow->getViewManager()->study();
334   SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(aSUITStudy);
335   _PTR(Study) aCStudy = VISU::GetCStudy(anAppStudy);
336   if (!myAnimator && !aCStudy->GetProperties()->IsLocked()) {
337     mySaveChk = new QCheckBox ("Save to presentation", this);
338     mySaveChk->setChecked(false);
339     aMainLayout->addWidget(mySaveChk);
340   } else {
341     mySaveChk = 0;
342   }
343
344   // Common buttons ===========================================================
345   QGroupBox* GroupButtons = new QGroupBox( this );
346   //GroupButtons->setColumnLayout(0, Qt::Vertical );
347   //GroupButtons->layout()->setSpacing( 0 );
348   //GroupButtons->layout()->setMargin( 0 );
349   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
350   GroupButtonsLayout->setAlignment( Qt::AlignTop );
351   GroupButtonsLayout->setSpacing( 6 );
352   GroupButtonsLayout->setMargin( 11 );
353
354   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons );
355   buttonOk->setAutoDefault( TRUE );
356   buttonOk->setDefault( TRUE );
357   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
358   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
359
360   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons );
361   buttonCancel->setAutoDefault( TRUE );
362   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
363
364   aMainLayout->addWidget( GroupButtons );
365
366   connect( buttonOk,     SIGNAL( clicked() ),      this, SLOT( accept() ) );
367   connect( buttonCancel, SIGNAL( clicked() ),      this, SLOT( reject() ) );
368 }
369
370 void ArrangeDlg::accept()
371 {
372   if (myAnimator != NULL) {
373     acceptAnimation();
374   } else {
375     acceptViewWindow();
376   }
377   QDialog::accept();
378 }
379
380 void ArrangeDlg::onFieldChange(int theCurrent)
381 {
382   if (myCurrent != theCurrent) {
383     Offset& aOffs = myOffsets[myCurrent];
384     aOffs.myOffset[0] = myCoord[0]->value();
385     aOffs.myOffset[1] = myCoord[1]->value();
386     aOffs.myOffset[2] = myCoord[2]->value();
387   }
388   myCurrent = theCurrent;
389   const Offset& aNewOffs = myOffsets[myCurrent];
390   myCoord[0]->setValue(aNewOffs.myOffset[0]);
391   myCoord[1]->setValue(aNewOffs.myOffset[1]);
392   myCoord[2]->setValue(aNewOffs.myOffset[2]);
393 }
394
395 void ArrangeDlg::acceptAnimation()
396 {
397   if (getMode() == ManualMode) {
398     // Save from GUI
399     Offset& aOffs = myOffsets[myCurrent];
400     aOffs.myOffset[0] = myCoord[0]->value();
401     aOffs.myOffset[1] = myCoord[1]->value();
402     aOffs.myOffset[2] = myCoord[2]->value();
403
404     for (int i = 0; i < myAnimator->getNbFields(); i++) {
405       Offset aOffs = myOffsets[i];
406       myAnimator->getFieldData(i).myOffset[0] = aOffs.myOffset[0];
407       myAnimator->getFieldData(i).myOffset[1] = aOffs.myOffset[1];
408       myAnimator->getFieldData(i).myOffset[2] = aOffs.myOffset[2];
409     }
410   } else {
411     QApplication::setOverrideCursor( Qt::WaitCursor );
412     FieldData& aData = myAnimator->getFieldData(myFieldLst->currentRow());
413     if (aData.myPrs.empty())
414       GeneratePresentations(myFieldLst->currentRow(),myAnimator);
415     vtkFloatingPointType aBounds[6];
416     aData.myPrs[0]->GetBounds(aBounds);
417     vtkFloatingPointType aDist = 0;
418     int aAxis = getAxis();
419     switch (aAxis) {
420     case XAxis:
421       aDist = fabs(aBounds[1] - aBounds[0]);
422       break;
423     case YAxis:
424       aDist = fabs(aBounds[3] - aBounds[2]);
425       break;
426     case ZAxis:
427       aDist = fabs(aBounds[5] - aBounds[4]);
428     }
429
430     vtkFloatingPointType dx = fabs(aBounds[1] - aBounds[0]);
431     vtkFloatingPointType dy = fabs(aBounds[3] - aBounds[2]);
432     vtkFloatingPointType dz = fabs(aBounds[5] - aBounds[4]);
433     vtkFloatingPointType max = (dx > dy) ? dx : dy;
434     max = (dz > max) ? dz : max;
435     max /= 100.0;
436
437     if (aDist < max) {
438       // set base distance between centers of bounding boxes
439       // to minimal (but big enough) size of current bounding box
440       if (dx < max) dx = FLT_MAX;
441       if (dy < max) dy = FLT_MAX;
442       if (dz < max) dz = FLT_MAX;
443
444       aDist = (dx < dy) ? dx : dy;
445       aDist = (dz < aDist) ? dz : aDist;
446     }
447     aDist = aDist * getDistance();
448     for (int i = 0; i < myAnimator->getNbFields(); i++) {
449       myAnimator->getFieldData(i).myOffset[0] = 0;
450       myAnimator->getFieldData(i).myOffset[1] = 0;
451       myAnimator->getFieldData(i).myOffset[2] = 0;
452       myAnimator->getFieldData(i).myOffset[aAxis] = aDist * i;
453     }
454
455     QApplication::restoreOverrideCursor();
456   }
457 }
458
459 void ArrangeDlg::acceptViewWindow()
460 {
461   if (getMode() == ManualMode) {
462     // Save from GUI
463     Offset& aOffs = myOffsets[myCurrent];
464     aOffs.myOffset[0] = myCoord[0]->value();
465     aOffs.myOffset[1] = myCoord[1]->value();
466     aOffs.myOffset[2] = myCoord[2]->value();
467
468     QMap<VISU::Prs3d_i*, int>::Iterator it;
469     for (it = myPrsMap.begin(); it != myPrsMap.end(); ++it) {
470       VISU::Prs3d_i* aPrs = it.key();
471       Offset& aOffs = myOffsets[it.value()];
472       if (VISU_Actor* anActor = VISU::FindActor(myViewWindow, aPrs))
473         anActor->SetPosition(aOffs.myOffset);
474       if (mySaveChk)
475         if (mySaveChk->isChecked())
476           aPrs->SetOffset(aOffs.myOffset[0],aOffs.myOffset[1],aOffs.myOffset[2]);
477     }
478     QMap<VISU::PointMap3d_i*, int>::Iterator itt;
479     for (itt = myPointMapPrsMap.begin(); itt != myPointMapPrsMap.end(); ++itt) {
480       VISU::PointMap3d_i* aPrs = itt.key();
481       Offset& aOffs = myOffsets[itt.value()];
482       if (VISU_ActorBase* anActor = VISU::FindActorBase(myViewWindow, aPrs))
483         anActor->SetPosition(aOffs.myOffset);
484       if (mySaveChk)
485         if (mySaveChk->isChecked())
486           aPrs->SetOffset(aOffs.myOffset[0],aOffs.myOffset[1],aOffs.myOffset[2]);
487     }
488   } else {
489     vtkFloatingPointType aDist = 0;
490     vtkFloatingPointType aShift = 0;
491     vtkFloatingPointType aPrevDist = 0;
492     vtkFloatingPointType aPrevShift = 0;
493     int i = 0;
494     QMap<VISU::Prs3d_i*, int>::Iterator it;
495     for (it = myPrsMap.begin(); it != myPrsMap.end(); ++it, i++) {
496       VISU::Prs3d_i* aPrs = it.key();
497       if (VISU_Actor* aActor = VISU::FindActor(myViewWindow, aPrs)) {
498         int aAxis = getAxis();
499
500         vtkFloatingPointType aZeroOffset[3];
501         aZeroOffset[0] = aZeroOffset[1] = aZeroOffset[2] = 0;
502         aActor->SetPosition(aZeroOffset);
503         aActor->GetMapper()->Update();
504
505         vtkFloatingPointType aBounds[6];
506         aActor->GetBounds(aBounds);
507         switch (aAxis) {
508         case XAxis:
509           aDist = fabs(aBounds[1] - aBounds[0]);
510           break;
511         case YAxis:
512           aDist = fabs(aBounds[3] - aBounds[2]);
513           break;
514         case ZAxis:
515           aDist = fabs(aBounds[5] - aBounds[4]);
516         }
517         vtkFloatingPointType aOffset[3];
518         aOffset[0] = aOffset[1] = aOffset[2] = 0;
519         aOffset[aAxis] =
520           (aBounds[2*aAxis+1] < aBounds[2*aAxis]) ? -aBounds[2*aAxis+1] : -aBounds[2*aAxis];
521
522         if (i > 0) {
523           vtkFloatingPointType aCCDist = (aDist + aPrevDist) / 2.0;
524
525           vtkFloatingPointType dx = fabs(aBounds[1] - aBounds[0]);
526           vtkFloatingPointType dy = fabs(aBounds[3] - aBounds[2]);
527           vtkFloatingPointType dz = fabs(aBounds[5] - aBounds[4]);
528           vtkFloatingPointType max = (dx > dy) ? dx : dy;
529           max = (dz > max) ? dz : max;
530           max /= 100.0;
531
532           if (aCCDist < max) {
533             // set base distance between centers of bounding boxes
534             // to minimal (but big enough) size of current bounding box
535             if (dx < max) dx = FLT_MAX;
536             if (dy < max) dy = FLT_MAX;
537             if (dz < max) dz = FLT_MAX;
538
539             aCCDist = (dx < dy) ? dx : dy;
540             aCCDist = (dz < aCCDist) ? dz : aCCDist;
541           }
542
543           //-------------------------------->
544           //             aShift
545           //                                 aDist / 2
546           //                                 <-->
547           //            .--------------.     .------.
548           //----------->|              |     |      |
549           // aPrevShift '--------------'     '------'
550           //            <------>
551           //            aPrevDist / 2
552           //
553           //                    <--------------->
554           //                    (aDist + aPrevDist) * getDistance() / 2
555
556           aShift = aPrevShift + aPrevDist/2.0 + aCCDist*getDistance() - aDist/2.0;
557         }
558
559         aOffset[aAxis] += aShift;
560         aActor->SetPosition(aOffset);
561         if (mySaveChk)
562           if (mySaveChk->isChecked())
563             aPrs->SetOffset(aOffset[0],aOffset[1],aOffset[2]);
564
565         aPrevDist = aDist;
566         aPrevShift = aShift;
567       }
568     } // end of myPrsMap loop
569     // Loop in PointMap3D the same as previous loop
570     QMap<VISU::PointMap3d_i*, int>::Iterator itt;
571     for (itt = myPointMapPrsMap.begin(); itt != myPointMapPrsMap.end(); ++itt, i++) {
572       VISU::PointMap3d_i* aPrs = itt.key();
573       if (VISU_ActorBase* aActor = VISU::FindActorBase(myViewWindow, aPrs)) {
574         int aAxis = getAxis();
575
576         vtkFloatingPointType aZeroOffset[3];
577         aZeroOffset[0] = aZeroOffset[1] = aZeroOffset[2] = 0;
578         aActor->SetPosition(aZeroOffset);
579         aActor->GetMapper()->Update();
580
581         vtkFloatingPointType aBounds[6];
582         aActor->GetBounds(aBounds);
583         switch (aAxis) {
584         case XAxis:
585           aDist = fabs(aBounds[1] - aBounds[0]);
586           break;
587         case YAxis:
588           aDist = fabs(aBounds[3] - aBounds[2]);
589           break;
590         case ZAxis:
591           aDist = fabs(aBounds[5] - aBounds[4]);
592         }
593         vtkFloatingPointType aOffset[3];
594         aOffset[0] = aOffset[1] = aOffset[2] = 0;
595         aOffset[aAxis] =
596           (aBounds[2*aAxis+1] < aBounds[2*aAxis]) ? -aBounds[2*aAxis+1] : -aBounds[2*aAxis];
597
598         if (i > 0) {
599           vtkFloatingPointType aCCDist = (aDist + aPrevDist) / 2.0;
600
601           vtkFloatingPointType dx = fabs(aBounds[1] - aBounds[0]);
602           vtkFloatingPointType dy = fabs(aBounds[3] - aBounds[2]);
603           vtkFloatingPointType dz = fabs(aBounds[5] - aBounds[4]);
604           vtkFloatingPointType max = (dx > dy) ? dx : dy;
605           max = (dz > max) ? dz : max;
606           max /= 100.0;
607
608           if (aCCDist < max) {
609             // set base distance between centers of bounding boxes
610             // to minimal (but big enough) size of current bounding box
611             if (dx < max) dx = FLT_MAX;
612             if (dy < max) dy = FLT_MAX;
613             if (dz < max) dz = FLT_MAX;
614
615             aCCDist = (dx < dy) ? dx : dy;
616             aCCDist = (dz < aCCDist) ? dz : aCCDist;
617           }
618           aShift = aPrevShift + aPrevDist/2.0 + aCCDist*getDistance() - aDist/2.0;
619         }
620
621         aOffset[aAxis] += aShift;
622         aActor->SetPosition(aOffset);
623         if (mySaveChk)
624           if (mySaveChk->isChecked())
625             aPrs->SetOffset(aOffset[0],aOffset[1],aOffset[2]);
626
627         aPrevDist = aDist;
628         aPrevShift = aShift;
629       }
630     } // end of myPointMapPrsMap loop
631   }
632   myViewWindow->getRenderer()->ResetCameraClippingRange();
633   myViewWindow->Repaint();
634 }
635
636
637 //------------------------------------------------------------------------
638 //------------------------------------------------------------------------
639
640 class SetupDlg::LineEdit : public QLineEdit
641 {
642 public:
643   LineEdit( QWidget* p = 0 ) : QLineEdit( p ) {}
644   virtual ~LineEdit() {}
645
646 protected:
647   void    focusOutEvent( QFocusEvent* e )
648   {
649     QLineEdit::focusOutEvent( e );
650
651     if ( text().isEmpty() )
652       emit editingFinished();
653   }
654   void    keyPressEvent( QKeyEvent* e )
655   {
656     QLineEdit::keyPressEvent( e );
657
658     if ( text().isEmpty() && e->key() == Qt::Key_Return )
659       emit returnPressed();
660   }
661 };
662
663
664 //------------------------------------------------------------------------
665 //------------------------------------------------------------------------
666
667 SetupDlg::SetupDlg (QWidget* theParent,
668                     VisuGUI* theModule,
669                     VISU_TimeAnimation* theAnimator) :
670   QDialog(theParent,
671           Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
672   myAnimator(theAnimator),
673   myModule(theModule),
674   myIsRegenerate( false )
675 {
676   setModal( true );
677   setWindowTitle("Setup Animation");
678   setSizeGripEnabled( TRUE );
679
680   QVBoxLayout* aMainLayout = new QVBoxLayout(this);
681   aMainLayout->setMargin( 7 );
682   aMainLayout->setSpacing(5);
683
684   // Range of time stamps
685   myUseRangeBox = new QGroupBox("Use range of time stamps", this);
686   myUseRangeBox->setCheckable( true );
687   myUseRangeBox->setChecked(myAnimator->isRangeDefined());
688
689   QHBoxLayout* aRangeLayout = new QHBoxLayout( myUseRangeBox );
690   aRangeLayout->setMargin( 11 );
691   aRangeLayout->setSpacing( 6 );
692
693   double aMaxTime = myAnimator->getMaxTime();
694   double aMinTime = myAnimator->getMinTime();
695   double aStep = 1;
696   if( myAnimator->getNbFields() > 0 ) {
697     if ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL )
698       aStep = (aMaxTime - aMinTime) / (myAnimator->getFieldData(0).myNbTimes - 1);
699     else { // successive animation mode
700       std::pair<int,long> aLastFieldFrame(myAnimator->getNbFields() - 1,
701                                           myAnimator->getFieldData(myAnimator->getNbFields() - 1).myNbTimes - 1);
702       aStep = (aMaxTime - aMinTime) / myAnimator->getAbsoluteFrameNumber(aLastFieldFrame);
703     }
704   }
705
706   QLabel* aMinLbl = new QLabel("From", myUseRangeBox);
707   aRangeLayout->addWidget(aMinLbl);
708   //myMinVal = new QtxDoubleSpinBox( aMinTime, aMaxTime, aStep, myUseRangeBox );
709   myMinVal = new LineEdit( myUseRangeBox );
710   myMinVal->setValidator( new QDoubleValidator( myMinVal ) );
711   if ( myUseRangeBox->isChecked() )
712     myMinVal->setText( QString::number( myAnimator->getMinRange() ) );
713   else
714     myMinVal->setText( QString::number( aMinTime ) );
715
716   //  connect(myMinVal, SIGNAL( valueChanged(double)),
717   //      this, SLOT( onMinValue(double) ));
718   connect( myMinVal, SIGNAL( returnPressed() ), this, SLOT( onMinValue() ) );
719   connect( myMinVal, SIGNAL( editingFinished() ), this, SLOT( onMinValue() ) );
720 //   connect( myMinVal, SIGNAL( textChanged(const QString&)),
721 //        this, SLOT( onMinValueEdit(const QString&) ));
722   aRangeLayout->addWidget(myMinVal);
723
724   QLabel* aMaxLbl = new QLabel("To", myUseRangeBox);
725   aRangeLayout->addWidget(aMaxLbl);
726   //myMaxVal = new QtxDoubleSpinBox( aMinTime, aMaxTime, aStep, myUseRangeBox );
727   myMaxVal = new LineEdit( myUseRangeBox );
728   myMaxVal->setValidator( new QDoubleValidator( myMaxVal ) );
729   if ( myUseRangeBox->isChecked() )
730     myMaxVal->setText( QString::number( myAnimator->getMaxRange() ) );
731   else
732     myMaxVal->setText( QString::number( aMaxTime ) );
733
734   //  connect(myMaxVal, SIGNAL( valueChanged(double)),
735   //      this, SLOT( onMaxValue(double) ));
736   connect( myMaxVal, SIGNAL( returnPressed() ), this, SLOT( onMaxValue() ) );
737   connect( myMaxVal, SIGNAL( editingFinished() ), this, SLOT( onMaxValue() ) );
738 //   connect(myMaxVal, SIGNAL( textChanged(const QString&)),
739 //        this, SLOT( onMaxValueEdit(const QString&) ));
740   aRangeLayout->addWidget(myMaxVal);
741
742   connect(myUseRangeBox, SIGNAL( toggled(bool)),
743           this, SLOT( onRangeCheck(bool) ));
744
745   aMainLayout->addWidget(myUseRangeBox);
746
747   // Sequence of time stamps
748   myUseSequenceBox = new QGroupBox("Use sequence of time stamps", this);
749   myUseSequenceBox->setCheckable( true );
750   myUseSequenceBox->setChecked( myAnimator->isSequenceDefined() );
751
752   QGridLayout* aUseSequenceLayout = new QGridLayout( myUseSequenceBox );
753   aUseSequenceLayout->setAlignment( Qt::AlignTop );
754   aUseSequenceLayout->setSpacing( 6 );
755   aUseSequenceLayout->setMargin( 11 );
756
757   QLabel* anIndicesLbl = new QLabel("Indices", myUseSequenceBox);
758   myIndices = new QLineEdit( myUseSequenceBox );
759
760   myValues = new QListWidget( myUseSequenceBox );
761   myValues->setSelectionMode( QAbstractItemView::ExtendedSelection );
762
763   connect(myIndices, SIGNAL( textChanged(const QString&)),
764           this, SLOT( onIndicesChanged(const QString&) ));
765
766   connect(myValues, SIGNAL( itemSelectionChanged() ),
767           this, SLOT( onValuesChanged() ) );
768
769   connect(myUseSequenceBox, SIGNAL( toggled(bool)),
770           this, SLOT( onSequenceCheck(bool) ));
771
772   aUseSequenceLayout->addWidget( anIndicesLbl, 0, 0 );
773   aUseSequenceLayout->addWidget( myIndices, 0, 1 );
774   aUseSequenceLayout->addWidget( myValues, 1, 1, 1, 2 );
775
776   aMainLayout->addWidget(myUseSequenceBox);
777
778   // Fields and Properties
779   QWidget* aPropFrame = new QWidget(this);
780   QHBoxLayout* aHPropLayout = new QHBoxLayout( aPropFrame );
781   aHPropLayout->setSpacing(5);
782   aHPropLayout->setMargin(0);
783
784   QGroupBox* aNamesBox = new QGroupBox("Fields",aPropFrame);
785   aHPropLayout->addWidget( aNamesBox );
786   QVBoxLayout* aVBoxLayout = new QVBoxLayout( aNamesBox );
787
788   myFieldLst = new QListWidget(aNamesBox);
789   aVBoxLayout->addWidget( myFieldLst );
790   QStringList aFieldNames;
791   // Find names of fields
792   for (int i = 0; i < myAnimator->getNbFields(); i++) {
793     _PTR(SObject) aSO = myAnimator->getFieldData(i).myField;
794     VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aSO);
795     QString aFieldName(aRestoringMap["myName"]);
796     if ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL )
797       aFieldNames.append(aFieldName);
798     else if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) {
799       _PTR(SObject) aSObject = aSO->GetFather()->GetFather()->GetFather();
800       VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aSObject);
801       QString aFileName(aRestoringMap["myInitFileName"]);
802       aFileName = aFileName.right(aFileName.length() - (aFileName.lastIndexOf("/") + 1));
803       aFieldNames.append(aFileName + QString(" : ") + aFieldName);
804     }
805   }
806   myFieldLst->addItems(aFieldNames);
807
808   if ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) {
809     myFieldLst->setCurrentRow(0);
810     connect( myFieldLst, SIGNAL( currentRowChanged(int) ),
811              this, SLOT( onFieldChange(int) ) );
812   }
813   else if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE )
814     myFieldLst->setSelectionMode(QAbstractItemView::NoSelection);
815
816   QWidget* aSetupBox = new QWidget(aPropFrame);
817   aHPropLayout->addWidget( aSetupBox );
818   aVBoxLayout = new QVBoxLayout( aSetupBox );
819   aVBoxLayout->setSpacing(5);
820   aVBoxLayout->setMargin(0);
821
822   QGroupBox* aPropBox = new QGroupBox("Properties", aSetupBox);
823   aVBoxLayout->addWidget( aPropBox );
824   QVBoxLayout* aPropVBLay = new QVBoxLayout( aPropBox );
825
826   //QVGroupBox* aPropBox = new QVGroupBox("Properties", aPropFrame);
827   myTypeCombo = new QComboBox(aPropBox);
828   aPropVBLay->addWidget( myTypeCombo );
829   connect( myTypeCombo, SIGNAL( activated(int) ),
830            this, SLOT( onTypeChanged(int) ) );
831
832   //  QPushButton* aBarBtn = new QPushButton("Scalar Bar...", aPropBox);
833   //connect( aBarBtn, SIGNAL( clicked() ),
834   //       this, SLOT( onScalarBarDlg() ) );
835
836   myPropBtn = new QPushButton("Properties...", aPropBox);
837   myPropBtn->setAutoDefault( false );
838   aPropVBLay->addWidget( myPropBtn );
839   //  myPropBtn->setEnabled(myAnimator->getFieldData(0).myPrsType != VISU::TSCALARMAP);
840   connect( myPropBtn, SIGNAL( clicked() ),
841            this, SLOT( onPreferencesDlg() ) );
842
843   if (myAnimator->getNbFields() > 1 ) {
844     if( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) {
845       myArrangeBtn = new QPushButton("Arrange...", aSetupBox);
846       aVBoxLayout->addWidget( myArrangeBtn );
847       connect( myArrangeBtn, SIGNAL( clicked() ), this, SLOT( onArrangeDlg() ) );
848     }
849   }
850   onFieldChange(0);
851   aMainLayout->addWidget(aPropFrame);
852
853   QWidget* aBtnBox = new QWidget(this);
854   QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox);
855   aBtnLayout->setContentsMargins( 5, 5, 0, 5 );
856   //  aBtnLayout->addStretch();
857
858   QPushButton* closeBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox );
859   closeBtn->setAutoDefault( false );
860   aBtnLayout->addStretch();
861   aBtnLayout->addWidget( closeBtn );
862   connect( closeBtn, SIGNAL( clicked() ), this, SLOT( onClose() ) );
863
864   aMainLayout->addWidget( aBtnBox );
865 }
866
867 //------------------------------------------------------------------------
868 void SetupDlg::initialize()
869 {
870   myValues->clear();
871
872   _PTR(Study) aStudy = myAnimator->getStudy();
873
874   if( myAnimator->getNbFields() == 0 )
875     return;
876
877   FieldData& aData = myAnimator->getFieldData( 0 );
878   _PTR(SObject) aField = aData.myField;
879
880   if ( !aField )
881     return;
882
883   _PTR(ChildIterator) anIter = aStudy->NewChildIterator(aField);
884   anIter->Next(); // First is reference on support
885   for(int index = 1; anIter->More(); anIter->Next(), index++)
886   {
887     double aTime = VISU_TimeAnimation::getTimeValue(anIter->Value());
888     QString itemText = QString("[%1] - %2").arg( index ).arg( aTime );
889
890     myValues->addItem( itemText );
891   }
892
893   QString anIndices( myAnimator->getAnimationSequence() );
894   myIndices->setText( anIndices );
895 }
896
897 //------------------------------------------------------------------------
898 enum PrsComboItem {
899   TSCALARMAP_ITEM     = 0, // VISU::TSCALARMAP
900   TISOSURFACES_ITEM   = 1, // VISU::TISOSURFACES
901   TCUTPLANES_ITEM     = 2, // VISU::TCUTPLANES
902   TCUTLINES_ITEM      = 3, // VISU::TCUTLINES
903   TPLOT3D_ITEM        = 4, // VISU::TPLOT3D
904   TDEFORMEDSHAPE_ITEM = 5, // VISU::TDEFORMEDSHAPE
905   TVECTORS_ITEM       = 6, // VISU::TVECTORS
906   TSTREAMLINES_ITEM   = 7, // VISU::TSTREAMLINES
907   TGAUSSPOINTS_ITEM   = 8, // VISU::TGAUSSPOINTS
908   TDEFORMEDSHAPEANDSCALARMAP_ITEM = 9 // VISU::TDEFORMEDSHAPEANDSCALARMAP
909 };
910
911 //------------------------------------------------------------------------
912 void SetupDlg::onClose()
913 {
914   if ( !myUseRangeBox->isChecked() )
915     myAnimator->setAnimationRange( 0, 0 );
916   else
917   {
918     double min = myMinVal->text().toDouble();
919     double max = myMaxVal->text().toDouble();
920     myAnimator->setAnimationRange( qMin( min, max ), qMax( min, max ) );
921   }
922
923   if ( !myUseSequenceBox->isChecked() )
924     myAnimator->setAnimationSequence( 0 );
925
926   close();
927 }
928
929 //------------------------------------------------------------------------
930 void SetupDlg::onFieldChange (int theIndex)
931 {
932   myTypeCombo->clear();
933   myTypeId2ComboId.clear();
934   myComboId2TypeId.clear();
935
936   if( myAnimator->getNbFields() == 0 )
937     return;
938
939   // ATTENTION: append items in the same order like it is done in the PrsComboItem enumeration
940   myTypeCombo->addItem("Scalar Map");   // item 0
941   myTypeId2ComboId[TSCALARMAP_ITEM] = myComboId2TypeId.size();
942   myComboId2TypeId.push_back(TSCALARMAP_ITEM);;
943
944   myTypeCombo->addItem("Iso Surfaces"); // item 1
945   myTypeId2ComboId[TISOSURFACES_ITEM] = myComboId2TypeId.size();
946   myComboId2TypeId.push_back(TISOSURFACES_ITEM);;
947
948   myTypeCombo->addItem("Cut Planes");   // item 2
949   myTypeId2ComboId[TCUTPLANES_ITEM] = myComboId2TypeId.size();
950   myComboId2TypeId.push_back(TCUTPLANES_ITEM);;
951
952   myTypeCombo->addItem("Cut Lines");   // item 3
953   myTypeId2ComboId[TCUTLINES_ITEM] = myComboId2TypeId.size();
954   myComboId2TypeId.push_back(TCUTLINES_ITEM);;
955
956   myTypeCombo->addItem("Plot 3D");      // item 4
957   myTypeId2ComboId[TPLOT3D_ITEM] = myComboId2TypeId.size();
958   myComboId2TypeId.push_back(TPLOT3D_ITEM);;
959
960   bool anEnableItems = false;
961   bool anEnableGP = false;
962   VISU::VISUType aPrsType;
963   if ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) { // parallel animation mode
964
965     FieldData& aData = myAnimator->getFieldData(theIndex);
966     _PTR(SObject) aSObject = aData.myField;
967     VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aSObject);
968     long aNumComp = aRestoringMap["myNumComponent"].toLong();
969     anEnableItems = (aNumComp > 1);
970
971     long anEntityId = aRestoringMap["myEntityId"].toLong();
972     anEnableGP = (anEntityId == VISU::CELL);
973
974     aPrsType = aData.myPrsType;
975
976   }
977   else if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) { // successive animation mode
978
979     for (int i = 0; i < myAnimator->getNbFields(); i++) {
980       _PTR(SObject) aSO = myAnimator->getFieldData(i).myField;
981       VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aSO);
982       long aNumComp = aRestoringMap["myNumComponent"].toLong();
983       anEnableItems = (aNumComp > 1);
984
985       long anEntityId = aRestoringMap["myEntityId"].toLong();
986       anEnableGP = (anEntityId == VISU::CELL);
987
988       if ( !anEnableItems && !anEnableGP ) break;
989     }
990
991     aPrsType = myAnimator->getFieldData(0).myPrsType;
992
993   }
994
995   if (anEnableItems) {
996     myTypeCombo->addItem("Deformed Shape"); // item 5
997     myTypeId2ComboId[TDEFORMEDSHAPE_ITEM] = myComboId2TypeId.size();
998     myComboId2TypeId.push_back(TDEFORMEDSHAPE_ITEM);;
999
1000     myTypeCombo->addItem("Vectors");        // item 6
1001     myTypeId2ComboId[TVECTORS_ITEM] = myComboId2TypeId.size();
1002     myComboId2TypeId.push_back(TVECTORS_ITEM);;
1003
1004     myTypeCombo->addItem("Stream Lines");   // item 7
1005     myTypeId2ComboId[TSTREAMLINES_ITEM] = myComboId2TypeId.size();
1006     myComboId2TypeId.push_back(TSTREAMLINES_ITEM);;
1007
1008     myTypeCombo->addItem("Deformed shape and Scalar map");   // item 9
1009     myTypeId2ComboId[TDEFORMEDSHAPEANDSCALARMAP_ITEM] = myComboId2TypeId.size();
1010     myComboId2TypeId.push_back(TDEFORMEDSHAPEANDSCALARMAP_ITEM);;
1011   }
1012
1013   if(anEnableGP){
1014     myTypeCombo->addItem("Gauss Points");   // item 8
1015     myTypeId2ComboId[TGAUSSPOINTS_ITEM] = myComboId2TypeId.size();
1016     myComboId2TypeId.push_back(TGAUSSPOINTS_ITEM);;
1017   }
1018
1019   switch (aPrsType) {
1020   case VISU::TSCALARMAP: //Scalar Map
1021     myTypeCombo->setCurrentIndex(myTypeId2ComboId[TSCALARMAP_ITEM]);
1022     break;
1023   case VISU::TISOSURFACES: //Iso Surfaces
1024     myTypeCombo->setCurrentIndex(myTypeId2ComboId[TISOSURFACES_ITEM]);
1025     break;
1026   case VISU::TCUTPLANES: //Cut Planes
1027     myTypeCombo->setCurrentIndex(myTypeId2ComboId[TCUTPLANES_ITEM]);
1028     break;
1029   case VISU::TCUTLINES: //Cut Lines
1030     myTypeCombo->setCurrentIndex(myTypeId2ComboId[TCUTLINES_ITEM]);
1031     break;
1032   case VISU::TPLOT3D: //Plot 3D
1033     myTypeCombo->setCurrentIndex(myTypeId2ComboId[TPLOT3D_ITEM]);
1034     break;
1035   case VISU::TDEFORMEDSHAPE: //Deformed Shape
1036     myTypeCombo->setCurrentIndex(myTypeId2ComboId[TDEFORMEDSHAPE_ITEM]);
1037     break;
1038   case VISU::TSCALARMAPONDEFORMEDSHAPE: //Scalar Map on Deformed Shape
1039   case VISU::TDEFORMEDSHAPEANDSCALARMAP:
1040     myTypeCombo->setCurrentIndex(myTypeId2ComboId[TDEFORMEDSHAPEANDSCALARMAP_ITEM]);
1041     break;
1042   case VISU::TVECTORS: //Vectors
1043     myTypeCombo->setCurrentIndex(myTypeId2ComboId[TVECTORS_ITEM]);
1044     break;
1045   case VISU::TSTREAMLINES: //Stream Lines
1046     myTypeCombo->setCurrentIndex(myTypeId2ComboId[TSTREAMLINES_ITEM]);
1047     break;
1048   case VISU::TGAUSSPOINTS: //Gauss Points
1049     myTypeCombo->setCurrentIndex(myTypeId2ComboId[TGAUSSPOINTS_ITEM]);
1050     break;
1051   }
1052   //myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP);
1053 }
1054
1055 //------------------------------------------------------------------------
1056 void SetupDlg::onTypeChanged (int theIndex)
1057 {
1058   int aType = myComboId2TypeId[theIndex];
1059
1060   for (int i = 0; i < myAnimator->getNbFields(); i++) {
1061     FieldData& aData = ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) ?
1062       myAnimator->getFieldData(myFieldLst->currentRow()) :
1063       myAnimator->getFieldData(i);
1064
1065     switch (aType) {
1066     case TSCALARMAP_ITEM: //Scalar Map
1067       aData.myPrsType = VISU::TSCALARMAP;
1068       break;
1069     case TISOSURFACES_ITEM: //Iso Surfaces
1070       aData.myPrsType = VISU::TISOSURFACES;
1071       break;
1072     case TCUTPLANES_ITEM: //Cut Planes
1073       aData.myPrsType = VISU::TCUTPLANES;
1074       break;
1075     case TCUTLINES_ITEM: //Cut Lines
1076       aData.myPrsType = VISU::TCUTLINES;
1077       break;
1078     case TPLOT3D_ITEM: //Plot 3D
1079       aData.myPrsType = VISU::TPLOT3D;
1080       break;
1081     case TDEFORMEDSHAPE_ITEM: //Deformed Shape
1082       aData.myPrsType = VISU::TDEFORMEDSHAPE;
1083       break;
1084     case TDEFORMEDSHAPEANDSCALARMAP_ITEM: //Scalar Map on Deformed Shape
1085       aData.myPrsType = VISU::TDEFORMEDSHAPEANDSCALARMAP;
1086       break;
1087     case TVECTORS_ITEM: //Vectors
1088       aData.myPrsType = VISU::TVECTORS;
1089       break;
1090     case TSTREAMLINES_ITEM: //Stream Lines
1091       aData.myPrsType = VISU::TSTREAMLINES;
1092       break;
1093     case TGAUSSPOINTS_ITEM: //Gauss Points
1094       aData.myPrsType = VISU::TGAUSSPOINTS;
1095       break;
1096     }
1097     myAnimator->clearData(aData);
1098
1099     if ( myAnimator->getAnimationMode() == VISU::Animation::PARALLEL ) // parallel animation mode
1100       break;
1101   }
1102   //myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP);
1103   //myAnimator->generatePresentations(myFieldLst->currentItem());
1104 }
1105
1106
1107 //------------------------------------------------------------------------
1108 namespace
1109 {
1110   template<class TPrs3d, class TDialog>
1111   void
1112   EditPrs(VisuGUI* theModule,
1113           FieldData& theData,
1114           VISU_TimeAnimation* theAnimator)
1115   {
1116     TDialog* aDlg = new TDialog(theModule);
1117     TPrs3d* aPrs3d = dynamic_cast<TPrs3d*>(theData.myPrs[0]);
1118     aDlg->initFromPrsObject(aPrs3d, true);
1119     if (aDlg->exec() && aDlg->storeToPrsObject(dynamic_cast<TPrs3d*>(aPrs3d))) {
1120
1121       for (long aFrameId = 1; aFrameId < theData.myNbFrames; aFrameId++){
1122         VISU::ColoredPrs3d_i* aColoredPrs3d = theData.myPrs[aFrameId];
1123         aColoredPrs3d->SameAs(aPrs3d);
1124       }
1125
1126       if ( theAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) {
1127         for (int aFieldId = 1; aFieldId < theAnimator->getNbFields(); aFieldId++) {
1128           FieldData& aFieldData = theAnimator->getFieldData(aFieldId);
1129           for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) {
1130             VISU::ColoredPrs3d_i* aColoredPrs3d = aFieldData.myPrs[aFrameId];
1131             std::string aTitle = aColoredPrs3d->GetCTitle();
1132             aColoredPrs3d->SameAs(aPrs3d);
1133             aColoredPrs3d->SetTitle(aTitle.c_str());
1134           }
1135         }
1136       }
1137     }
1138     delete aDlg;
1139   }
1140 }
1141
1142
1143 void SetupDlg::onPreferencesDlg()
1144 {
1145   if(myAnimator->getNbFields() == 0){
1146     SUIT_MessageBox::warning(this,
1147                            tr("ERROR"),
1148                            VisuGUI_TimeAnimationDlg::tr("MSG_NO_ANIMATIONDATA"),
1149                            tr("&OK"));
1150     return;
1151   }
1152
1153   SUIT_OverrideCursor c;
1154
1155   VISU::Animation::AnimationMode aMode = myAnimator->getAnimationMode();
1156   int aRefFieldId = ( aMode == VISU::Animation::PARALLEL ) ? myFieldLst->currentRow() : 0;
1157   FieldData& aData = myAnimator->getFieldData(aRefFieldId);
1158   if (aData.myPrs.empty())
1159     myAnimator->generatePresentations(aRefFieldId);
1160
1161   if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) {
1162     for (int i = 0; i < myAnimator->getNbFields(); i++) {
1163       if ( i != aRefFieldId && myAnimator->getFieldData(i).myPrs.empty() )
1164         myAnimator->generatePresentations(i);
1165     }
1166   }
1167
1168   if(!aData.myNbFrames || aData.myPrs.empty() || !aData.myPrs[0]){
1169     QApplication::restoreOverrideCursor();
1170     SUIT_MessageBox::warning(this,
1171                            tr("ERROR"),
1172                            VisuGUI_TimeAnimationDlg::tr("MSG_NO_ANIMATIONDATA"),
1173                            tr("&OK"));
1174     return;
1175   }
1176
1177   int aType = myComboId2TypeId[myTypeCombo->currentIndex()];
1178   switch (aType) {
1179   case TSCALARMAP_ITEM: //Scalar Map
1180     c.suspend();
1181     EditPrs<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg>(myModule,aData,myAnimator);
1182     break;
1183   case TISOSURFACES_ITEM: //Iso Surfaces
1184     c.suspend();
1185     EditPrs<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg>(myModule,aData,myAnimator);
1186     break;
1187   case TCUTPLANES_ITEM: //Cut Planes
1188     c.suspend();
1189     EditPrs<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg>(myModule,aData,myAnimator);
1190     break;
1191   case TCUTLINES_ITEM: //Cut Lines
1192     c.suspend();
1193     EditPrs<VISU::CutLines_i,VisuGUI_CutLinesDlg>(myModule,aData,myAnimator);
1194     break;
1195   case TPLOT3D_ITEM: //Plot 3D
1196     c.suspend();
1197     EditPrs<VISU::Plot3D_i,VisuGUI_Plot3DDlg>(myModule,aData,myAnimator);
1198     break;
1199   case TDEFORMEDSHAPE_ITEM: //Deformed Shape
1200     c.suspend();
1201     EditPrs<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg>(myModule,aData,myAnimator);
1202     break;
1203   case TDEFORMEDSHAPEANDSCALARMAP_ITEM: //Scalar Map on Deformed Shape
1204     c.suspend();
1205     {
1206       typedef VisuGUI_DeformedShapeAndScalarMapDlg DLG;
1207       typedef VISU::DeformedShapeAndScalarMap_i TYPE;
1208       DLG* aDlg = new DLG (myModule);
1209       TYPE* aPrs3d = dynamic_cast<TYPE*>(aData.myPrs[0]);
1210       aDlg->initFromPrsObject(aPrs3d, true);
1211       if (aDlg->exec() && aDlg->storeToPrsObject(aData.myPrs[0])) {
1212         for (long aFrameId = 1; aFrameId < aData.myNbFrames; aFrameId++){
1213           TYPE* aDeformedPrs3d = dynamic_cast<TYPE*>(aData.myPrs[aFrameId]);
1214           //Set correct time stamp number
1215           int aTimeStampNum = aDeformedPrs3d->GetScalarTimeStampNumber();
1216           aDeformedPrs3d->SameAs(aPrs3d);
1217           aDeformedPrs3d->SetScalarField(aDeformedPrs3d->GetScalarEntity(),
1218                                          aDeformedPrs3d->GetScalarFieldName(),
1219                                          aTimeStampNum);
1220
1221         }
1222
1223         if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) {
1224           for (int aFieldId = 1; aFieldId < myAnimator->getNbFields(); aFieldId++) {
1225             FieldData& aFieldData = myAnimator->getFieldData(aFieldId);
1226             for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) {
1227               TYPE* aDeformedPrs3d = dynamic_cast<TYPE*>(aFieldData.myPrs[aFrameId]);
1228               std::string aTitle = aDeformedPrs3d->GetCTitle();
1229               //Set correct time stamp number
1230               int aTimeStampNum = aDeformedPrs3d->GetScalarTimeStampNumber();
1231               aDeformedPrs3d->SameAs(aPrs3d);
1232               aDeformedPrs3d->SetTitle(aTitle.c_str());
1233               aDeformedPrs3d->SetScalarField(aDeformedPrs3d->GetScalarEntity(),
1234                                              aDeformedPrs3d->GetScalarFieldName(),
1235                                              aTimeStampNum);
1236
1237             }
1238           }
1239         }
1240       }
1241       delete aDlg;
1242     }
1243     break;
1244   case TVECTORS_ITEM: //Vectors
1245     c.suspend();
1246     EditPrs<VISU::Vectors_i,VisuGUI_VectorsDlg>(myModule,aData,myAnimator);
1247     break;
1248   case TSTREAMLINES_ITEM: //Stream Lines
1249     c.suspend();
1250     EditPrs<VISU::StreamLines_i,VisuGUI_StreamLinesDlg>(myModule,aData,myAnimator);
1251     break;
1252   case TGAUSSPOINTS_ITEM: //Gauss Points
1253     c.suspend();
1254     EditPrs<VISU::GaussPoints_i,VisuGUI_GaussPointsDlg>(myModule,aData,myAnimator);
1255     break;
1256   }
1257 }
1258
1259
1260 //------------------------------------------------------------------------
1261 void SetupDlg::onArrangeDlg()
1262 {
1263   ArrangeDlg aDlg(this, myAnimator);
1264   aDlg.exec();
1265 }
1266
1267 //------------------------------------------------------------------------
1268 void SetupDlg::onRangeCheck (bool theCheck)
1269 {
1270   if( theCheck )
1271   {
1272     myUseSequenceBox->blockSignals( true );
1273     myUseSequenceBox->setChecked( false );
1274     myUseSequenceBox->blockSignals( false );
1275   }
1276
1277   if (!theCheck)
1278     myAnimator->setAnimationRange(0, 0);
1279   else
1280     myAnimator->setAnimationRange(myMinVal->text().toDouble(), myMaxVal->text().toDouble());
1281
1282   setIsRegenerate( true );
1283 }
1284
1285 //------------------------------------------------------------------------
1286 void SetupDlg::onMinValue()
1287 {
1288   double aVal = myMinVal->text().toDouble();
1289   aVal = qMax( qMin( aVal, myAnimator->getMaxRange() ), myAnimator->getMinTime() );
1290   myAnimator->setAnimationRange( aVal, myAnimator->getMaxRange() );
1291   myMinVal->setText( QString::number( aVal ) );
1292   myMinVal->setFocus();
1293
1294   setIsRegenerate( true );
1295 }
1296
1297 //------------------------------------------------------------------------
1298 void SetupDlg::onMaxValue()
1299 {
1300   double aVal = myMaxVal->text().toDouble();
1301   aVal = qMin( qMax( aVal, myAnimator->getMinRange() ), myAnimator->getMaxTime() );
1302   myAnimator->setAnimationRange( myAnimator->getMinRange(), aVal );
1303   myMaxVal->setText( QString::number( aVal ) );
1304   myMaxVal->setFocus();
1305
1306   setIsRegenerate( true );
1307 }
1308
1309 //------------------------------------------------------------------------
1310 void SetupDlg::onMinValueEdit (const QString& theVal)
1311 {
1312   double aVal = theVal.toDouble();
1313   if ((aVal > myAnimator->getMaxRange()) || (aVal < myAnimator->getMinRange())){
1314     myMinVal->setText( QString::number(myAnimator->getMinTime()) );
1315     myMinVal->setFocus();
1316     return;
1317   }
1318 }
1319
1320 //------------------------------------------------------------------------
1321 void SetupDlg::onMaxValueEdit (const QString& theVal)
1322 {
1323   double aVal = theVal.toDouble();
1324   if ((aVal > myAnimator->getMaxRange()) || (aVal < myAnimator->getMinRange())) {
1325     myMaxVal->setText( QString::number(myAnimator->getMaxTime()) );
1326     myMaxVal->setFocus();
1327   }
1328 }
1329
1330 //------------------------------------------------------------------------
1331 void SetupDlg::onSequenceCheck( bool theCheck )
1332 {
1333   if( theCheck )
1334   {
1335     myUseRangeBox->blockSignals( true );
1336     myUseRangeBox->setChecked( false );
1337     myUseRangeBox->blockSignals( false );
1338   }
1339
1340   QString anIndices = myIndices->text();
1341   myAnimator->setAnimationSequence( anIndices.toLatin1().data() );
1342
1343   setIsRegenerate( true );
1344 }
1345
1346 //------------------------------------------------------------------------
1347 void SetupDlg::onIndicesChanged( const QString& theIndices )
1348 {
1349   bool aCorrect = true;
1350   int aLimit = myValues->count();
1351
1352   QList<long> anIndicesList;
1353   aCorrect = myAnimator->getIndicesFromSequence( theIndices, anIndicesList );
1354
1355   myValues->blockSignals( true );
1356   myValues->clearSelection();
1357
1358   QList<long>::iterator indIt = anIndicesList.begin();
1359   QList<long>::iterator indItEnd = anIndicesList.end();
1360   for( int i = 0; indIt != indItEnd; ++indIt, i++ )
1361   {
1362     long anIndex = *indIt;
1363     if( anIndex < 1 || anIndex > aLimit )
1364     {
1365       aCorrect = false;
1366       myValues->clearSelection();
1367       break;
1368     }
1369     myValues->item( anIndex-1 )->setSelected( true );
1370   }
1371
1372   myValues->blockSignals( false );
1373
1374   QPalette palette = myIndices->palette();
1375
1376   if( !aCorrect )
1377   {
1378     palette.setColor(myIndices->foregroundRole(), Qt::red);
1379     myIndices->setPalette(palette);
1380     return;
1381   }
1382
1383   palette.setColor(myIndices->foregroundRole(), Qt::black);
1384   myIndices->setPalette(palette);
1385
1386   myAnimator->setAnimationSequence( theIndices.toLatin1().data() );
1387
1388   setIsRegenerate( true );
1389 }
1390
1391 //------------------------------------------------------------------------
1392 void SetupDlg::onValuesChanged()
1393 {
1394   int aLimit = myValues->count();
1395
1396   QString anIndices;
1397
1398   for( int i = 0; i < aLimit; i++ )
1399   {
1400     if( !myValues->item( i )->isSelected() )
1401       continue;
1402
1403     QString aString = QString::number( i+1 );
1404
1405     bool aPrevSelected = i != 0 && myValues->item( i-1 )->isSelected();
1406     bool aNextSelected = i != aLimit - 1 && myValues->item( i+1 )->isSelected();
1407     if( aPrevSelected )
1408     {
1409       if( aNextSelected )
1410         aString = "";
1411       else
1412         aString += ",";
1413     }
1414     else
1415     {
1416       if( aNextSelected )
1417         aString += "-";
1418       else
1419         aString += ",";
1420     }
1421
1422     anIndices += aString;
1423   }
1424
1425   if( anIndices.right( 1 ) == "," )
1426     anIndices.truncate( anIndices.length() - 1 );
1427
1428   myIndices->blockSignals( true );
1429
1430   QPalette palette = myIndices->palette();
1431   palette.setColor(myIndices->foregroundRole(), Qt::black);
1432   myIndices->setPalette(palette);
1433
1434   myIndices->setText( anIndices );
1435   myIndices->blockSignals( false );
1436
1437   myAnimator->setAnimationSequence( anIndices.toLatin1().data() );
1438
1439   setIsRegenerate( true );
1440 }
1441
1442 //------------------------------------------------------------------------
1443 static const char * firstIco[] = {
1444 "18 10 2 1",
1445 "       g None",
1446 ".      g #000000",
1447 "         .     .  ",
1448 "  ..    ..    ..  ",
1449 "  ..   ...   ...  ",
1450 "  ..  ....  ....  ",
1451 "  .. ..... .....  ",
1452 "  .. ..... .....  ",
1453 "  ..  ....  ....  ",
1454 "  ..   ...   ...  ",
1455 "  ..    ..    ..  ",
1456 "         .     .  "};
1457
1458
1459 static const char * lastIco[] = {
1460 "18 10 2 1",
1461 "       g None",
1462 ".      g #000000",
1463 "  .     .         ",
1464 "  ..    ..    ..  ",
1465 "  ...   ...   ..  ",
1466 "  ....  ....  ..  ",
1467 "  ..... ..... ..  ",
1468 "  ..... ..... ..  ",
1469 "  ....  ....  ..  ",
1470 "  ...   ...   ..  ",
1471 "  ..    ..    ..  ",
1472 "  .     .         "};
1473
1474
1475 static const char * leftIco[] = {
1476 "11 10 2 1",
1477 "       g None",
1478 ".      g #000000",
1479 "    .     .",
1480 "   ..    ..",
1481 "  ...   ...",
1482 " ....  ....",
1483 "..... .....",
1484 "..... .....",
1485 " ....  ....",
1486 "  ...   ...",
1487 "   ..    ..",
1488 "    .     ."};
1489
1490 static const char * playIco[] = {
1491 "14 14 2 1",
1492 "       g None",
1493 ".      g #000000",
1494 "              ",
1495 "              ",
1496 "  ..          ",
1497 "  ....        ",
1498 "  ......      ",
1499 "  ........    ",
1500 "  ..........  ",
1501 "  ..........  ",
1502 "  ........    ",
1503 "  ......      ",
1504 "  ....        ",
1505 "  ..          ",
1506 "              ",
1507 "              "};
1508
1509 static QPixmap MYplayPixmap(playIco);
1510
1511
1512 static const char * rightIco[] = {
1513 "11 10 2 1",
1514 "       g None",
1515 ".      g #000000",
1516 ".     .    ",
1517 "..    ..   ",
1518 "...   ...  ",
1519 "....  .... ",
1520 "..... .....",
1521 "..... .....",
1522 "....  .... ",
1523 "...   ...  ",
1524 "..    ..   ",
1525 ".     .    "};
1526
1527
1528 static const char * pauseIco[] = {
1529 "14 14 2 1",
1530 "       g None",
1531 ".      g #000000",
1532 "              ",
1533 "              ",
1534 "   ..    ..   ",
1535 "   ..    ..   ",
1536 "   ..    ..   ",
1537 "   ..    ..   ",
1538 "   ..    ..   ",
1539 "   ..    ..   ",
1540 "   ..    ..   ",
1541 "   ..    ..   ",
1542 "   ..    ..   ",
1543 "   ..    ..   ",
1544 "              ",
1545 "              "};
1546
1547 static QPixmap MYpausePixmap(pauseIco);
1548
1549
1550 VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule,
1551                                                     _PTR(Study) theStudy,
1552                                                     VISU::Animation::AnimationMode theMode) :
1553   QDialog(VISU::GetDesktop(theModule),
1554           Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
1555   myModule(theModule),
1556   mySetupDlg(NULL)
1557 {
1558   setAttribute( Qt::WA_DeleteOnClose, true );
1559   setModal( false );
1560   if ( theMode == VISU::Animation::PARALLEL )
1561     setWindowTitle(tr("PARALLEL_ANIMATION"));
1562   else
1563     setWindowTitle(tr("SUCCESSIVE_ANIMATION"));
1564   setSizeGripEnabled( TRUE );
1565
1566   myAnimator = new VISU_TimeAnimation (theStudy);
1567   myAnimator->setViewer(VISU::GetActiveViewWindow<SVTK_ViewWindow>(theModule));
1568   connect(myAnimator, SIGNAL(frameChanged(long, double)), this, SLOT(onExecution(long, double)));
1569   connect(myAnimator, SIGNAL(stopped()),                  this, SLOT(onStop()));
1570   myAnimator->setAnimationMode(theMode);
1571
1572   QVBoxLayout* aMainLayout = new QVBoxLayout(this);
1573   aMainLayout->setMargin( 7 );
1574   aMainLayout->setSpacing(5);
1575
1576   mySetupBtn = new QPushButton("Setup Animation...", this);
1577   connect( mySetupBtn, SIGNAL( clicked() ),
1578            this, SLOT( onSetupDlg() ) );
1579   aMainLayout->addWidget(mySetupBtn);
1580
1581   myGenBtn = new QPushButton("Generate frames", this);
1582   connect( myGenBtn, SIGNAL( clicked() ),
1583            this, SLOT( createFrames() ) );
1584   aMainLayout->addWidget(myGenBtn);
1585
1586   myPlayFrame = new QFrame(this);
1587   myPlayFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
1588   myPlayFrame->setLineWidth( 1 );
1589
1590
1591   // --- Play controls ---
1592   QGridLayout* TopLayout = new QGridLayout( myPlayFrame );
1593   TopLayout->setSpacing( 6 );
1594   TopLayout->setMargin( 11 );
1595
1596   myTimeLbl = new QLabel("0", myPlayFrame);
1597   TopLayout->addWidget(myTimeLbl, 0, 0, 1, 3, Qt::AlignHCenter);
1598
1599   mySlider = new QSlider( myPlayFrame);
1600   mySlider->setOrientation(Qt::Horizontal);
1601   mySlider->setMinimum(0);
1602   mySlider->setMaximum(3);
1603   mySlider->setTickInterval(1);
1604   //mySlider->setTickmarks(QSlider::Below);
1605   mySlider->setTracking(false);
1606   connect( mySlider, SIGNAL( sliderMoved(int) ),
1607            this, SLOT( onWindowChanged(int) ) );
1608   TopLayout->addWidget(mySlider, 1, 0, 1, 3);
1609
1610   myPlayBtn = new QPushButton(myPlayFrame);
1611   myPlayBtn->setIcon(MYplayPixmap);
1612   myPlayBtn->setCheckable(true);
1613   connect( myPlayBtn, SIGNAL( clicked() ),
1614            this, SLOT( onPlayPressed() ) );
1615   TopLayout->addWidget(myPlayBtn, 2, 0, 1, 2);
1616
1617   QPushButton* aBackBtn = new QPushButton(myPlayFrame);
1618   aBackBtn->setIcon(QPixmap(leftIco));
1619   connect( aBackBtn, SIGNAL( clicked() ),
1620            this, SLOT( onBackPressed() ) );
1621   TopLayout->addWidget(aBackBtn, 3, 0);
1622
1623   QPushButton* aForvardBtn = new QPushButton(myPlayFrame);
1624   aForvardBtn->setIcon(QPixmap(rightIco));
1625   connect( aForvardBtn, SIGNAL( clicked() ),
1626            this, SLOT( onForvardPressed() ) );
1627   TopLayout->addWidget(aForvardBtn, 3, 1);
1628
1629   QPushButton* aFirstBtn = new QPushButton(myPlayFrame);
1630   aFirstBtn->setIcon(QPixmap(firstIco));
1631   connect( aFirstBtn, SIGNAL( clicked() ),
1632            this, SLOT( onFirstPressed() ) );
1633   TopLayout->addWidget(aFirstBtn, 4, 0);
1634
1635   QPushButton* aLastBtn = new QPushButton(myPlayFrame);
1636   aLastBtn->setIcon(QPixmap(lastIco));
1637   connect( aLastBtn, SIGNAL( clicked() ),
1638            this, SLOT( onLastPressed() ) );
1639   TopLayout->addWidget(aLastBtn, 4, 1);
1640
1641   QLabel* aSpeedLbl = new QLabel("Speed", myPlayFrame);
1642   TopLayout->addWidget(aSpeedLbl, 4, 2, Qt::AlignRight);
1643
1644   QLCDNumber* aSpeedNum  = new QLCDNumber( 2, myPlayFrame );
1645   aSpeedNum->setSegmentStyle(QLCDNumber::Flat);
1646   aSpeedNum->display((int)myAnimator->getSpeed());
1647   TopLayout->addWidget(aSpeedNum, 4, 3);
1648
1649   QwtWheel* aWheel = new QwtWheel(myPlayFrame);
1650   aWheel->setOrientation(Qt::Vertical);
1651   aWheel->setRange(1, 99, 1);
1652   aWheel->setValue((int)myAnimator->getSpeed());
1653   connect( aWheel, SIGNAL(valueChanged(double)),
1654            aSpeedNum, SLOT(display(double)) );
1655   connect( aWheel, SIGNAL(valueChanged(double)),
1656            this, SLOT(onSpeedChange(double)) );
1657   TopLayout->addWidget(aWheel, 1, 3, 3, 1, Qt::AlignRight);
1658
1659   QCheckBox* aCycleCheck = new QCheckBox("Cycled animation",myPlayFrame);
1660   aCycleCheck->setChecked(myAnimator->isCycling());
1661   connect(aCycleCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setCyclingSlot(bool)));
1662   TopLayout->addWidget(aCycleCheck, 5, 0, 1, 4);
1663
1664   QCheckBox* aPropCheck = new QCheckBox("Use proportional timing",myPlayFrame);
1665   aPropCheck->setChecked(myAnimator->isProportional());
1666   connect(aPropCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setProportionalSlot(bool)));
1667   TopLayout->addWidget(aPropCheck, 6, 0, 1, 4);
1668
1669   // Pictures saving on disk
1670   QGroupBox* aSaveBox = new QGroupBox( "Saving", myPlayFrame );
1671   //aSaveBox->setColumnLayout(0, Qt::Horizontal );
1672   QGridLayout* aSaveLay = new QGridLayout(aSaveBox);
1673   aSaveLay->setSpacing( 5 );
1674   aSaveLay->setMargin( 5 );
1675
1676   mySaveCheck = new QCheckBox("Save pictures to directory", aSaveBox);
1677   connect(mySaveCheck, SIGNAL( toggled(bool)),
1678           this, SLOT( onCheckDump(bool) ));
1679   aSaveLay->addWidget(mySaveCheck, 0, 0, 1, 3);
1680
1681   QLabel* aFormatLbl = new QLabel("Saving format:", aSaveBox);
1682   aFormatLbl->setEnabled(false);
1683   connect(mySaveCheck, SIGNAL( toggled(bool)),
1684           aFormatLbl, SLOT( setEnabled(bool) ));
1685   aSaveLay->addWidget(aFormatLbl, 1, 0, 1, 2);
1686
1687   myPicsFormat = new QComboBox(aSaveBox);
1688   QList<QByteArray> aDumpFormats = QImageWriter::supportedImageFormats();
1689   for (unsigned int i = 0; i < aDumpFormats.count(); i++) {
1690     myPicsFormat->addItem(aDumpFormats.at(i));
1691   }
1692   if (aDumpFormats.indexOf("jpeg") >= 0)
1693     myPicsFormat->setCurrentIndex(aDumpFormats.indexOf("jpeg"));
1694   else
1695     myPicsFormat->setCurrentIndex(0);
1696
1697   myPicsFormat->setEnabled(false);
1698   aSaveLay->addWidget(myPicsFormat, 1, 2);
1699   connect(mySaveCheck, SIGNAL( toggled(bool)),
1700           myPicsFormat, SLOT( setEnabled(bool) ));
1701   connect(myPicsFormat, SIGNAL(  activated (int)),
1702           this, SLOT( onPicsFormatChanged()));
1703
1704   QLabel* aPathLbl = new QLabel("Path:", aSaveBox);
1705   aPathLbl->setEnabled(false);
1706   connect(mySaveCheck, SIGNAL( toggled(bool)),
1707           aPathLbl, SLOT( setEnabled(bool) ));
1708   aSaveLay->addWidget(aPathLbl, 2, 0);
1709
1710   myPathEdit = new QLineEdit(aSaveBox);
1711   myPathEdit->setReadOnly(true);
1712   myPathEdit->setEnabled(false);
1713   connect(mySaveCheck, SIGNAL( toggled(bool)),
1714           myPathEdit, SLOT( setEnabled(bool) ));
1715   aSaveLay->addWidget(myPathEdit, 2, 1);
1716
1717   QPushButton* aBrowseBtn = new QPushButton("Browse...", aSaveBox);
1718   aBrowseBtn->setEnabled(false);
1719   connect(mySaveCheck, SIGNAL( toggled(bool)),
1720           aBrowseBtn, SLOT( setEnabled(bool) ));
1721   connect(aBrowseBtn, SIGNAL( clicked()),
1722           this, SLOT( onBrowse() ));
1723   mySaveCheck->setChecked(false);
1724   aSaveLay->addWidget(aBrowseBtn, 2, 2);
1725
1726   mySaveAVICheck = new QCheckBox("Save animation to AVI file", aSaveBox);
1727   connect(mySaveAVICheck, SIGNAL( toggled(bool)),
1728           this, SLOT( onCheckDump(bool) ));
1729   aSaveLay->addWidget(mySaveAVICheck, 3, 0, 1, 3);
1730
1731   myPathAVILbl = new QLabel("Path:", aSaveBox);
1732   myPathAVILbl->setEnabled(false);
1733   //connect(mySaveAVICheck, SIGNAL( toggled(bool)),
1734   //        myPathAVILbl, SLOT( setEnabled(bool) ));
1735   aSaveLay->addWidget(myPathAVILbl, 4, 0);
1736
1737   myPathAVIEdit = new QLineEdit(aSaveBox);
1738   myPathAVIEdit->setReadOnly(true);
1739   myPathAVIEdit->setEnabled(false);
1740   //connect(mySaveAVICheck, SIGNAL( toggled(bool)),
1741   //        myPathAVIEdit, SLOT( setEnabled(bool) ));
1742   aSaveLay->addWidget(myPathAVIEdit, 4, 1);
1743
1744   myBrowseAVIBtn = new QPushButton("Browse...", aSaveBox);
1745   myBrowseAVIBtn->setEnabled(false);
1746   //connect(mySaveAVICheck, SIGNAL( toggled(bool)),
1747   //        myBrowseAVIBtn, SLOT( setEnabled(bool) ));
1748   connect(myBrowseAVIBtn, SIGNAL( clicked()),
1749           this, SLOT( onBrowseAVI() ));
1750   aSaveLay->addWidget(myBrowseAVIBtn, 4, 2);
1751
1752   mySaveAVICheck->setChecked(false);
1753   //mySaveAVICheck->setEnabled(myAnimator->checkAVIMaker());
1754
1755   TopLayout->addWidget(aSaveBox, 7, 0, 1, 4);
1756
1757   QCheckBox* aCleanMemCheck = new QCheckBox("Clean memory at each frame",myPlayFrame);
1758   aCleanMemCheck->setChecked(myAnimator->isCleaningMemoryAtEachFrame());
1759   connect(aCleanMemCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setCleaningMemoryAtEachFrameSlot(bool)));
1760   TopLayout->addWidget(aCleanMemCheck, 8, 0, 1, 4);
1761
1762   aMainLayout->addWidget(myPlayFrame);
1763
1764   // Animation publishing in study
1765   QWidget* aPublishBox = new QWidget(this);
1766   QHBoxLayout* aPubHBLay = new QHBoxLayout( aPublishBox );
1767   aPubHBLay->setMargin( 0 );
1768
1769   myPublishBtn = new QPushButton("Publish to study", aPublishBox);
1770   aPubHBLay->addWidget( myPublishBtn );
1771   connect(myPublishBtn, SIGNAL(clicked()), this, SLOT(publishToStudy()));
1772
1773   mySaveBtn = new QPushButton("Save Animation", aPublishBox);
1774   mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
1775   aPubHBLay->addWidget( mySaveBtn );
1776   connect(mySaveBtn, SIGNAL(clicked()), this, SLOT(saveToStudy()));
1777
1778   aMainLayout->addWidget(aPublishBox);
1779
1780
1781   QWidget* aBtnBox = new QWidget(this);
1782   QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox);
1783   aBtnLayout->setContentsMargins( 5, 5, 0, 5 );
1784   aBtnLayout->addStretch();
1785
1786   QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox);
1787   aBtnLayout->addWidget( aCloseBtn );
1788   connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close()));
1789
1790   QPushButton* aHelpBtn = new QPushButton(tr("BUT_HELP"), aBtnBox);
1791   aBtnLayout->addWidget( aHelpBtn );
1792   connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
1793
1794   SUIT_Study* aStudy = VISU::GetAppStudy(myModule);
1795   connect(aStudy, SIGNAL(destroyed()), this, SLOT(close()));
1796
1797   connect(myAnimator->getViewer(), SIGNAL(destroyed()), this, SLOT(close()));
1798   connect(myAnimator->getViewer(), SIGNAL(closing(SUIT_ViewWindow*)), this, SLOT(close()));
1799
1800   aMainLayout->addWidget(aBtnBox);
1801
1802   myPlayFrame->setEnabled(false);
1803 }
1804
1805 //------------------------------------------------------------------------
1806 VisuGUI_TimeAnimationDlg::~VisuGUI_TimeAnimationDlg()
1807 {
1808   if (myAnimator != NULL) {
1809     delete myAnimator;
1810     myAnimator = NULL;
1811     if ( VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule) )
1812       VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule)->Repaint();
1813   }
1814 }
1815
1816 //------------------------------------------------------------------------
1817 void VisuGUI_TimeAnimationDlg::onTypeChange (int index)
1818 {
1819   stopAnimation();
1820   myPropBtn->setEnabled(index != 0);
1821
1822   clearView();
1823   myPlayFrame->setEnabled(false);
1824 }
1825
1826 //------------------------------------------------------------------------
1827 bool VisuGUI_TimeAnimationDlg::addField (_PTR(SObject) theSObject)
1828 {
1829   myPlayFrame->setEnabled(false);
1830   return myAnimator->addField(theSObject);
1831 }
1832
1833 //------------------------------------------------------------------------
1834 void VisuGUI_TimeAnimationDlg::createFrames()
1835 {
1836   stopAnimation();
1837   SUIT_OverrideCursor c;
1838
1839   bool isRegenerate = mySetupDlg->isRegenerate();
1840
1841   for (int i = 0; i < myAnimator->getNbFields(); i++) {
1842     FieldData& aFieldData = myAnimator->getFieldData(i);
1843     if( aFieldData.myPrs.empty() )
1844     {
1845       //myAnimator->generatePresentations(i);
1846       GeneratePresentations(i,myAnimator);
1847       continue;
1848     }
1849
1850     // ouv : IPAL18064
1851     // even if aFieldData is not empty, we must regenerate presentations,
1852     // when a range or a sequence of the animation has been changed
1853     if( isRegenerate )
1854     {
1855       GeneratePresentations(i,myAnimator);
1856       /*
1857       VISU::ColoredPrs3d_i* aPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(aFieldData.myPrs[0]);
1858       if( !aPrs3d )
1859         continue;
1860
1861       myAnimator->generatePresentations(i);
1862
1863       aFieldData = myAnimator->getFieldData(i);
1864       for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) {
1865         VISU::ColoredPrs3d_i* aColoredPrs3d = aFieldData.myPrs[aFrameId];
1866         std::string aTitle = aColoredPrs3d->GetCTitle();
1867         aColoredPrs3d->SameAs(aPrs3d);
1868         if ( aFrameId != 0 && myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) {
1869           aColoredPrs3d->SetTitle(aTitle.c_str());
1870         }
1871       }
1872       */
1873     }
1874   }
1875   if( isRegenerate )
1876     mySetupDlg->setIsRegenerate( false );
1877
1878   if (myAnimator->getNbFrames() == 0) {
1879     myPlayFrame->setEnabled(false);
1880     c.suspend();
1881     SUIT_MessageBox::warning(this,
1882                            tr("ERROR"),
1883                            tr("MSG_NO_ANIMATIONDATA"),
1884                            tr("&OK"));
1885     return;
1886   }
1887   mySlider->setMaximum(myAnimator->getNbFrames()-1);
1888   myPlayFrame->setEnabled(true);
1889   if (!myAnimator->generateFrames()) {
1890     c.suspend();
1891     //myPlayFrame->setEnabled(false);
1892     SUIT_MessageBox::warning(this,
1893                            tr("ERROR"),
1894                            myAnimator->getLastErrorMsg(),
1895                            tr("&OK"));
1896     return;
1897   }
1898   //myPlayFrame->setEnabled(true);
1899 }
1900
1901 //------------------------------------------------------------------------
1902 void VisuGUI_TimeAnimationDlg::onPlayPressed()
1903 {
1904   if (myPlayBtn->isChecked() && (!myAnimator->isRunning())) {
1905     myPlayBtn->setIcon(MYpausePixmap);
1906     if (mySaveCheck->isChecked()) {
1907       onPicsFormatChanged();
1908       onPathChanged();
1909
1910     } else if (mySaveAVICheck->isChecked()) {
1911       myAnimator->setDumpFormat("AVI");
1912       myAnimator->dumpTo(myPathAVIEdit->text().toLatin1().data());
1913     } else {
1914       myAnimator->dumpTo("");
1915     }
1916     mySetupBtn->setEnabled(false);
1917     myGenBtn->setEnabled(false);
1918     myAnimator->startAnimation();
1919   } else {
1920     myPlayBtn->setIcon(MYplayPixmap);
1921     myAnimator->stopAnimation();
1922     mySetupBtn->setEnabled(true);
1923     myGenBtn->setEnabled(true);
1924   }
1925 }
1926
1927 //------------------------------------------------------------------------
1928 void VisuGUI_TimeAnimationDlg::onBackPressed()
1929 {
1930   //stopAnimation();
1931   myAnimator->prevFrame();
1932 }
1933
1934 //------------------------------------------------------------------------
1935 void VisuGUI_TimeAnimationDlg::onForvardPressed()
1936 {
1937   myAnimator->nextFrame();
1938 }
1939
1940 //------------------------------------------------------------------------
1941 void VisuGUI_TimeAnimationDlg::onLastPressed()
1942 {
1943   myAnimator->lastFrame();
1944 }
1945
1946 //------------------------------------------------------------------------
1947 void VisuGUI_TimeAnimationDlg::onFirstPressed()
1948 {
1949   myAnimator->firstFrame();
1950 }
1951
1952 //------------------------------------------------------------------------
1953 void VisuGUI_TimeAnimationDlg::clearView()
1954 {
1955   myAnimator->clearView();
1956 }
1957
1958 //------------------------------------------------------------------------
1959 void VisuGUI_TimeAnimationDlg::showEvent(QShowEvent* theEvent)
1960 {
1961   mySetupDlg = new SetupDlg(this,myModule, myAnimator);
1962   mySetupDlg->initialize();
1963 }
1964
1965 //------------------------------------------------------------------------
1966 void VisuGUI_TimeAnimationDlg::closeEvent (QCloseEvent* theEvent)
1967 {
1968   if (myAnimator != NULL) {
1969     myAnimator->stopAnimation();
1970     myAnimator->wait(500);
1971     if (myAnimator->isRunning() && (! myAnimator->isFinished())) {
1972       theEvent->ignore();
1973       QCloseEvent* aNewCloseEvent = new QCloseEvent;
1974       QApplication::postEvent( this, aNewCloseEvent );
1975     } else {
1976       QDialog::closeEvent(theEvent);
1977     }
1978   } else {
1979     QDialog::closeEvent(theEvent);
1980   }
1981 }
1982
1983 //------------------------------------------------------------------------
1984 void VisuGUI_TimeAnimationDlg::onWindowChanged (int index)
1985 {
1986   if (myAnimator->isRunning()) return;
1987   myAnimator->gotoFrame(index);
1988 }
1989
1990 //------------------------------------------------------------------------
1991 void VisuGUI_TimeAnimationDlg::onSpeedChange (double theSpeed)
1992 {
1993   myAnimator->setSpeed((int)theSpeed);
1994 }
1995
1996 //------------------------------------------------------------------------
1997 void VisuGUI_TimeAnimationDlg::stopAnimation()
1998 {
1999   myAnimator->stopAnimation();
2000   myPlayBtn->setChecked(false);
2001   myPlayBtn->setIcon(MYplayPixmap);
2002   mySetupBtn->setEnabled(true);
2003   myGenBtn->setEnabled(true);
2004 }
2005
2006 //------------------------------------------------------------------------
2007 void VisuGUI_TimeAnimationDlg::onExecution (long theNewFrame, double theTime)
2008 {
2009   myTimeLbl->setText(QString("%1").arg(theTime));
2010   mySlider->setValue(theNewFrame);
2011 }
2012
2013 //------------------------------------------------------------------------
2014 void VisuGUI_TimeAnimationDlg::onSetupDlg()
2015 {
2016   if (myAnimator->getNbFrames() > 0)
2017     myAnimator->firstFrame();
2018   mySetupDlg->exec();
2019   myPlayFrame->setEnabled(false);
2020 }
2021
2022 //------------------------------------------------------------------------
2023 void VisuGUI_TimeAnimationDlg::onBrowse()
2024 {
2025   //  QString aPath = SUIT_FileDlg::getExistingDirectory(this, "/", "Select path");
2026   QString aDir;
2027   if (myPathEdit->text().isEmpty())
2028     aDir = getenv("HOME");
2029   else
2030     aDir = myPathEdit->text();
2031   QString aPath = SUIT_FileDlg::getExistingDirectory(this, aDir, "Select path");
2032   if (!aPath.isEmpty())
2033     myPathEdit->setText(Qtx::addSlash(aPath));
2034   onPathChanged();
2035 }
2036
2037 //------------------------------------------------------------------------
2038 void VisuGUI_TimeAnimationDlg::onBrowseAVI()
2039 {
2040   QStringList aFilter;
2041   aFilter.append( "AVI Files (*.avi)" );
2042   aFilter.append( "All Files (*.*)" );
2043
2044   QString aDir;
2045   if (myPathAVIEdit->text().isEmpty())
2046     aDir = getenv("HOME");
2047   else {
2048     QFileInfo aFile(myPathAVIEdit->text());
2049     aDir = aFile.absoluteDir().absolutePath();
2050   }
2051   QString aPath = SUIT_FileDlg::getFileName(this, aDir, aFilter, "Select file", false);
2052   if (!aPath.isEmpty())
2053     myPathAVIEdit->setText(aPath);
2054 }
2055
2056 //------------------------------------------------------------------------
2057 void VisuGUI_TimeAnimationDlg::onCheckDump(bool)
2058 {
2059   const QObject* source = sender();
2060   if (source == mySaveCheck) {
2061     if (mySaveCheck->isChecked()) {
2062       onPicsFormatChanged();
2063       onPathChanged();
2064       if (mySaveAVICheck->isChecked())
2065         mySaveAVICheck->setChecked(false);
2066     } else {
2067       myAnimator->dumpTo("");
2068     }
2069     //mySaveAVICheck->setEnabled(!mySaveCheck->isChecked() && myAnimator->checkAVIMaker());
2070     mySaveAVICheck->setEnabled(!mySaveCheck->isChecked());
2071   }
2072   else if (source == mySaveAVICheck) {
2073     if (mySaveAVICheck->isChecked()) {
2074       if (!myAnimator->checkAVIMaker()) {
2075         // AVI maker is not available
2076         SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER"), tr("&OK"));
2077         mySaveAVICheck->setChecked(false);
2078       }
2079       else {
2080         if (mySaveCheck->isChecked()) {
2081           mySaveCheck->setChecked(false);
2082         }
2083         myPathAVILbl->setEnabled(true);
2084         myPathAVIEdit->setEnabled(true);
2085         myBrowseAVIBtn->setEnabled(true);
2086       }
2087     }
2088     else {
2089       // it is necessary in case of not available AVI maker,
2090       // because otherwise they will stay enabled
2091       // (??? slots, connected on SIGNAL(toggled(bool)) of mySaveAVICheck,
2092       // works in wrong order ???)
2093       myPathAVILbl->setEnabled(false);
2094       myPathAVIEdit->setEnabled(false);
2095       myBrowseAVIBtn->setEnabled(false);
2096     }
2097     mySaveCheck->setEnabled(!mySaveAVICheck->isChecked());
2098   }
2099 }
2100
2101 //------------------------------------------------------------------------
2102 void VisuGUI_TimeAnimationDlg::onStop()
2103 {
2104   myPlayBtn->setChecked(false);
2105   myPlayBtn->setIcon(MYplayPixmap);
2106   mySetupBtn->setEnabled(true);
2107   myGenBtn->setEnabled(true);
2108 }
2109
2110 //------------------------------------------------------------------------
2111 void VisuGUI_TimeAnimationDlg::onHelp()
2112 {
2113   QString aHelpFileName = "animating_page.html";
2114   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
2115   if (app)
2116     app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName);
2117   else {
2118                 QString platform;
2119 #ifdef WIN32
2120                 platform = "winapplication";
2121 #else
2122                 platform = "application";
2123 #endif
2124     SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
2125                            QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
2126                            arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
2127                            QObject::tr("BUT_OK"));
2128   }
2129 }
2130
2131 //------------------------------------------------------------------------
2132 void VisuGUI_TimeAnimationDlg::saveToStudy()
2133 {
2134   myAnimator->saveAnimation();
2135   VISU::UpdateObjBrowser(myModule, true);
2136 }
2137
2138 //------------------------------------------------------------------------
2139 void VisuGUI_TimeAnimationDlg::publishToStudy()
2140 {
2141   myAnimator->publishInStudy();
2142   VISU::UpdateObjBrowser(myModule, true);
2143   mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
2144 }
2145
2146 //------------------------------------------------------------------------
2147 void VisuGUI_TimeAnimationDlg::restoreFromStudy(_PTR(SObject) theAnimation)
2148 {
2149   myAnimator->restoreFromStudy(theAnimation);
2150   mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
2151   if ( myAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE )
2152     setWindowTitle(tr("SUCCESSIVE_ANIMATION"));
2153 }
2154
2155 //------------------------------------------------------------------------
2156 void VisuGUI_TimeAnimationDlg::onPicsFormatChanged()
2157 {
2158   QList<QByteArray> aDumpFormats = QImageWriter::supportedImageFormats();
2159   if (aDumpFormats.count() < 1) {
2160     SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_SUPPORTED_IMAGE_FORMATS"), tr("&OK"));
2161     return;
2162   }
2163   if (myPicsFormat->currentIndex() < 0 || aDumpFormats.count() <= myPicsFormat->currentIndex()) {
2164     SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_INVALID_IMAGE_FORMAT_INDEX"), tr("&OK"));
2165     return;
2166   }
2167   myAnimator->setDumpFormat(aDumpFormats.at(myPicsFormat->currentIndex()));
2168 }
2169
2170 //------------------------------------------------------------------------
2171 void VisuGUI_TimeAnimationDlg::onPathChanged()
2172 {
2173   myAnimator->dumpTo(myPathEdit->text().toLatin1().data());
2174 }
2175
2176 //------------------------------------------------------------------------
2177 void VisuGUI_TimeAnimationDlg::keyPressEvent( QKeyEvent* e )
2178 {
2179   QDialog::keyPressEvent( e );
2180   if ( e->isAccepted() )
2181     return;
2182
2183   if ( e->key() == Qt::Key_F1 )
2184     {
2185       e->accept();
2186       onHelp();
2187     }
2188 }