]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_TimeAnimation.cxx
Salome HOME
IPAL8983: Close study during animation playing - SIGILL
[modules/visu.git] / src / VISUGUI / VisuGUI_TimeAnimation.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : VisuGUI_TimeAnimation.cxx
8 //  Author : Vitaly SMETANNIKOV
9 //  Module : VISU
10
11 #include "VisuGUI_TimeAnimation.h"
12
13 #include "VisuGUI.h"
14 #include "VisuGUI_Tools.h"
15 #include "VisuGUI_DeformedShapeDlg.h"
16 #include "VisuGUI_CutPlanesDlg.h"
17 #include "VisuGUI_Plot3DDlg.h"
18 #include "VisuGUI_VectorsDlg.h"
19 #include "VisuGUI_IsoSurfacesDlg.h"
20 #include "VisuGUI_StreamLinesDlg.h"
21
22 #include "VISU_TimeAnimation.h"
23
24 #include "VISU_ScalarMap_i.hh"
25 #include "VISU_IsoSurfaces_i.hh"
26 #include "VISU_DeformedShape_i.hh"
27 #include "VISU_CutPlanes_i.hh"
28 #include "VISU_Plot3D_i.hh"
29 #include "VISU_CutLines_i.hh"
30 #include "VISU_Vectors_i.hh"
31 #include "VISU_StreamLines_i.hh"
32
33 #include "VISU_ViewManager_i.hh"
34
35 #include "VISU_ScalarBarActor.hxx"
36 #include "VISU_Actor.h"
37
38 #include "SalomeApp_Study.h"
39 #include "SalomeApp_Application.h"
40
41 #include "SVTK_ViewWindow.h"
42
43 #include "SUIT_OverrideCursor.h"
44 #include "SUIT_MessageBox.h"
45 #include "SUIT_Desktop.h"
46 #include "SUIT_FileDlg.h"
47
48 #include <vtkRenderer.h>
49
50 #include <qhbox.h>
51 #include <qgrid.h>
52 #include <qlayout.h>
53 #include <qslider.h>
54 #include <qthread.h>
55 #include <qlistbox.h>
56 #include <qwt_wheel.h>
57 #include <qhgroupbox.h>
58 #include <qlcdnumber.h>
59 #include <qvgroupbox.h>
60
61 #define  MAXVAL 1e10
62
63 ArrangeDlg::ArrangeDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator)
64   : QDialog(theParent, "ArrangeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
65     myAnimator(theAnimator), myViewWindow(theAnimator->getViewer())
66 {
67   myCurrent = 0;
68   init();
69   QStringList aFieldNames;
70   // Find names of fields
71   for (int i = 0; i < theAnimator->getNbFields(); i++) {
72     aFieldNames.append(VISU::getValue(theAnimator->getFieldData(i).myField, "myName"));
73     Offset aOffs;
74     aOffs.myOffset[0] = myAnimator->getFieldData(i).myOffset[0];
75     aOffs.myOffset[1] = myAnimator->getFieldData(i).myOffset[1];
76     aOffs.myOffset[2] = myAnimator->getFieldData(i).myOffset[2];
77     myOffsets.append(aOffs);
78   }
79   myFieldLst->insertStringList(aFieldNames);
80   myFieldLst->setSelected(0, true);
81 }
82
83 ArrangeDlg::ArrangeDlg(QWidget* theParent, SVTK_ViewWindow* theViewWindow)
84   : QDialog(theParent, "ArrangeDlg", true, WStyle_Customize |
85             WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
86     myAnimator(0), myViewWindow(theViewWindow)
87 {
88   myCurrent = 0;
89   init();
90   QStringList aPrsNames;
91   vtkActor* anActor;
92   vtkActorCollection *anActColl = myViewWindow->getRenderer()->GetActors();
93   for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;) {
94     VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor);
95     if (anVISUActor)
96       if (anVISUActor->GetVisibility() != 0) {
97         VISU::Prs3d_i* aPrs = anVISUActor->GetParent()->GetPrs3d();
98         if (aPrs) {
99           if (!myPrsMap.contains(aPrs)) {
100             SALOMEDS::SObject_var aSObject = aPrs->GetSObject();
101             if(!aSObject->_is_nil()){
102               SALOMEDS::GenericAttribute_var anAttr;
103               if (aSObject->FindAttribute(anAttr, "AttributeName")) {
104                 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
105                 string aNam = aName->Value();
106                 QString strIn(aNam.c_str());
107                 aPrsNames.append(strIn);
108                 myPrsMap[aPrs] = myOffsets.count();
109                 Offset aOffs;
110                 anVISUActor->GetPosition(aOffs.myOffset);
111                 myOffsets.append(aOffs);
112               }
113             }
114           }
115         }
116       }
117   }
118   myFieldLst->insertStringList(aPrsNames);
119   myFieldLst->setSelected(0, true);
120 }
121
122 void ArrangeDlg::init()
123 {
124   setCaption("Arrange Presentations");
125   setSizeGripEnabled( TRUE );
126
127   QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6);
128   aMainLayout->setSpacing(5);
129
130   QButtonGroup* aBtnGrp = new QButtonGroup(2, Qt::Horizontal, this);
131   aBtnGrp->setExclusive(true);
132   aMainLayout->addWidget(aBtnGrp);
133
134   QRadioButton* aAutoBtn = new QRadioButton("Auto", aBtnGrp);
135   aBtnGrp->insert(aAutoBtn, AutoMode);
136
137   QRadioButton* aManualBtn = new QRadioButton("Manual", aBtnGrp);
138   aBtnGrp->insert(aManualBtn, ManualMode);
139   aBtnGrp->setButton(AutoMode);
140
141   myStackWgt = new QWidgetStack(this);
142   aMainLayout->addWidget(myStackWgt);
143
144   //  AUTO Pane
145   QVBox* aAutoPane = new QVBox(myStackWgt);
146   aAutoPane->setSpacing(5);
147   // Axis Group
148   myAxisGrp = new QButtonGroup(3, Qt::Horizontal,"Axis", aAutoPane);
149
150   QRadioButton* aXBtn = new QRadioButton("X",myAxisGrp );
151   myAxisGrp->insert(aXBtn, XAxis);
152
153   QRadioButton* aYBtn = new QRadioButton("Y",myAxisGrp );
154   myAxisGrp->insert(aYBtn, YAxis);
155
156   QRadioButton* aZBtn = new QRadioButton("Z",myAxisGrp );
157   myAxisGrp->insert(aZBtn, ZAxis);
158
159   myAxisGrp->setButton(XAxis);
160
161   //Distance Input
162   QHBox* aDistPane = new QHBox(aAutoPane);
163   aDistPane->setSpacing(5);
164   new QLabel("Relative Distance", aDistPane);
165   myDistVal = new QtxDblSpinBox (-10,10, 0.5, aDistPane);
166   myDistVal->setValue(1);
167
168   myStackWgt->addWidget(aAutoPane, AutoMode);
169
170   // Manual Pane
171   QHBox* aManualPane = new QHBox(myStackWgt);
172   aManualPane->setSpacing(10);
173
174   myFieldLst = new QListBox(aManualPane);
175   connect( myFieldLst, SIGNAL( highlighted(int) ),
176            this, SLOT( onFieldChange(int) ) );
177
178   QGrid* aCoordPane = new QGrid(2, aManualPane);
179   aCoordPane->setSpacing(5);
180
181   new QLabel("X", aCoordPane);
182   myCoord[0] = new QtxDblSpinBox(aCoordPane);
183   myCoord[0]->setRange(-MAXVAL, MAXVAL);
184
185   new QLabel("Y", aCoordPane);
186   myCoord[1] = new QtxDblSpinBox(aCoordPane);
187   myCoord[1]->setRange(-MAXVAL, MAXVAL);
188
189   new QLabel("Z", aCoordPane);
190   myCoord[2] = new QtxDblSpinBox(aCoordPane);
191   myCoord[2]->setRange(-MAXVAL, MAXVAL);
192
193   myStackWgt->addWidget(aManualPane, ManualMode);
194
195   myStackWgt->raiseWidget(AutoMode);
196
197   connect(aBtnGrp, SIGNAL(clicked(int)), myStackWgt, SLOT(raiseWidget(int)) );
198
199   SUIT_Study* aSUITStudy = myViewWindow->getViewManager()->study();
200   SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(aSUITStudy);
201   _PTR(Study) aCStudy = VISU::GetCStudy(anAppStudy);
202   if (!myAnimator && !aCStudy->GetProperties()->IsLocked()) {
203     mySaveChk = new QCheckBox ("Save to presentation", this);
204     mySaveChk->setChecked(false);
205     aMainLayout->addWidget(mySaveChk);
206   } else {
207     mySaveChk = 0;
208   }
209
210   // Common buttons ===========================================================
211   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
212   GroupButtons->setColumnLayout(0, Qt::Vertical );
213   GroupButtons->layout()->setSpacing( 0 );
214   GroupButtons->layout()->setMargin( 0 );
215   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
216   GroupButtonsLayout->setAlignment( Qt::AlignTop );
217   GroupButtonsLayout->setSpacing( 6 );
218   GroupButtonsLayout->setMargin( 11 );
219
220   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
221   buttonOk->setAutoDefault( TRUE );
222   buttonOk->setDefault( TRUE );
223   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
224   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
225
226   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
227   buttonCancel->setAutoDefault( TRUE );
228   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
229
230   aMainLayout->addWidget( GroupButtons );
231
232   connect( buttonOk,     SIGNAL( clicked() ),      this, SLOT( accept() ) );
233   connect( buttonCancel, SIGNAL( clicked() ),      this, SLOT( reject() ) );
234 }
235
236 void ArrangeDlg::accept()
237 {
238   if (myAnimator) {
239     acceptAnimation();
240   } else {
241     acceptViewWindow();
242   }
243   QDialog::accept();
244 }
245
246 void ArrangeDlg::onFieldChange(int theCurrent)
247 {
248   if (myCurrent != theCurrent) {
249     Offset& aOffs = myOffsets[myCurrent];
250     aOffs.myOffset[0] = myCoord[0]->value();
251     aOffs.myOffset[1] = myCoord[1]->value();
252     aOffs.myOffset[2] = myCoord[2]->value();
253   }
254   myCurrent = theCurrent;
255   const Offset& aNewOffs = myOffsets[myCurrent];
256   myCoord[0]->setValue(aNewOffs.myOffset[0]);
257   myCoord[1]->setValue(aNewOffs.myOffset[1]);
258   myCoord[2]->setValue(aNewOffs.myOffset[2]);
259 }
260
261 void ArrangeDlg::acceptAnimation()
262 {
263   if (getMode() == ManualMode) {
264     // Save from GUI
265     Offset& aOffs = myOffsets[myCurrent];
266     aOffs.myOffset[0] = myCoord[0]->value();
267     aOffs.myOffset[1] = myCoord[1]->value();
268     aOffs.myOffset[2] = myCoord[2]->value();
269
270     for (int i = 0; i < myAnimator->getNbFields(); i++) {
271       Offset aOffs = myOffsets[i];
272       myAnimator->getFieldData(i).myOffset[0] = aOffs.myOffset[0];
273       myAnimator->getFieldData(i).myOffset[1] = aOffs.myOffset[1];
274       myAnimator->getFieldData(i).myOffset[2] = aOffs.myOffset[2];
275     }
276   } else {
277     QApplication::setOverrideCursor( Qt::waitCursor );
278     FieldData& aData = myAnimator->getFieldData(0);
279     if (aData.myPrs.empty())
280       myAnimator->generatePresentations(0);
281     VISU_Actor* aActor = aActor = aData.myPrs[0]->CreateActor();
282     float aBounds[6];
283     aActor->GetBounds(aBounds);
284     aActor->Delete();
285     float aDist = 0;
286     int aAxis = getAxis();
287     switch (aAxis) {
288     case XAxis:
289       aDist = fabs(aBounds[1] - aBounds[0]);
290       break;
291     case YAxis:
292       aDist = fabs(aBounds[3] - aBounds[2]);
293       break;
294     case ZAxis:
295       aDist = fabs(aBounds[5] - aBounds[4]);
296     }
297     aDist = aDist*getDistance();
298     for (int i = 0; i < myAnimator->getNbFields(); i++) {
299       myAnimator->getFieldData(i).myOffset[0] = 0;
300       myAnimator->getFieldData(i).myOffset[1] = 0;
301       myAnimator->getFieldData(i).myOffset[2] = 0;
302       myAnimator->getFieldData(i).myOffset[aAxis] = aDist * i;
303     }
304
305     QApplication::restoreOverrideCursor();
306   }
307 }
308
309 void ArrangeDlg::acceptViewWindow()
310 {
311   if (getMode() == ManualMode) {
312     // Save from GUI
313     Offset& aOffs = myOffsets[myCurrent];
314     aOffs.myOffset[0] = myCoord[0]->value();
315     aOffs.myOffset[1] = myCoord[1]->value();
316     aOffs.myOffset[2] = myCoord[2]->value();
317
318     QMap<VISU::Prs3d_i*, int>::Iterator it;
319     for (it = myPrsMap.begin(); it != myPrsMap.end(); ++it) {
320       VISU::Prs3d_i* aPrs = it.key();
321       Offset& aOffs = myOffsets[it.data()];
322       if (VISU_Actor* anActor = VISU::GetActor(aPrs, myViewWindow)) anActor->SetPosition(aOffs.myOffset);
323       if (mySaveChk)
324         if (mySaveChk->isChecked())
325           aPrs->SetOffset(aOffs.myOffset);
326     }
327   } else {
328     float aDist = 0;
329     float aShift = 0;
330     float aPrevDist = 0;
331     //    bool aInit = true;
332     int i;
333     QMap<VISU::Prs3d_i*, int>::Iterator it;
334     for (it = myPrsMap.begin(), i = 0; it != myPrsMap.end(); ++it, i++) {
335       VISU::Prs3d_i* aPrs = it.key();
336       if (VISU_Actor* aActor = VISU::GetActor(aPrs, myViewWindow)){
337         int aAxis = getAxis();
338         //      if (aInit) {
339         float aBounds[6];
340         aActor->GetBounds(aBounds);
341         switch (aAxis) {
342         case XAxis:
343           aDist = fabs(aBounds[1] - aBounds[0]);
344           break;
345         case YAxis:
346           aDist = fabs(aBounds[3] - aBounds[2]);
347           break;
348         case ZAxis:
349           aDist = fabs(aBounds[5] - aBounds[4]);
350         }
351         //        aInit = false;
352         //      }
353         float aOffset[3];
354         aOffset[0] = aOffset[1] = aOffset[2] = 0;
355
356         aShift = (i == 0)? 0 : aShift + (aDist + aPrevDist) * getDistance() / 2;
357
358         aOffset[aAxis] = aShift;
359         aActor->SetPosition(aOffset);
360         if (mySaveChk)
361           if (mySaveChk->isChecked())
362             aPrs->SetOffset(aOffset);
363         aPrevDist = aDist;
364       }
365     }
366   }
367   myViewWindow->getRenderer()->ResetCameraClippingRange();
368   myViewWindow->Repaint();
369 }
370
371
372 //*****************************************************************************************************
373 //*****************************************************************************************************
374 //*****************************************************************************************************
375 SetupDlg::SetupDlg (VisuGUI* theModule, VISU_TimeAnimation* theAnimator)
376      : QDialog(VISU::GetDesktop(theModule), "SetupDlg", true, WStyle_Customize |
377                WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
378        myModule(theModule)
379 {
380   setCaption("Setup Animation");
381   setSizeGripEnabled( TRUE );
382   myAnimator = theAnimator;
383
384   QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6);
385   aMainLayout->setSpacing(5);
386
387
388   QFrame* aRangeGrp = new QFrame(this);
389   QGridLayout* aRangeLayout = new QGridLayout( aRangeGrp );
390   aRangeLayout->setSpacing( 6 );
391   aRangeLayout->setMargin( 11 );
392   aRangeGrp->setFrameStyle(QFrame::Box | QFrame::Raised);
393
394   myUseRangeChk = new QCheckBox("Use range of time stamps", aRangeGrp);
395   aRangeLayout->addMultiCellWidget(myUseRangeChk, 0, 0, 0, 3);
396   myUseRangeChk->setChecked(myAnimator->isRangeDefined());
397
398   QLabel* aMinLbl = new QLabel("From", aRangeGrp);
399   aMinLbl->setEnabled(myUseRangeChk->isChecked());
400   aRangeLayout->addWidget(aMinLbl, 1, 0);
401   double aStep = (myAnimator->getMaxTime() - myAnimator->getMinTime())/(theAnimator->getFieldData(0).myNbTimes - 1);
402   myMinVal = new QtxDblSpinBox( myAnimator->getMinTime(), myAnimator->getMaxTime(), aStep, aRangeGrp );
403   myMinVal->setEnabled(myUseRangeChk->isChecked());
404   if (myUseRangeChk->isChecked())
405     myMinVal->setValue( myAnimator->getMinRange() );
406   else
407     myMinVal->setValue( myAnimator->getMinTime() );
408
409   connect(myMinVal, SIGNAL( valueChanged(double)),
410           this, SLOT( onMinValue(double) ));
411   aRangeLayout->addWidget(myMinVal, 1, 1);
412
413   QLabel* aMaxLbl = new QLabel("To", aRangeGrp);
414   aMaxLbl->setEnabled(myUseRangeChk->isChecked());
415   aRangeLayout->addWidget(aMaxLbl, 1, 2);
416   myMaxVal = new QtxDblSpinBox( myAnimator->getMinTime(), myAnimator->getMaxTime(), aStep, aRangeGrp );
417   myMaxVal->setEnabled(myUseRangeChk->isChecked());
418   if (myUseRangeChk->isChecked())
419     myMaxVal->setValue( myAnimator->getMaxRange() );
420   else
421     myMaxVal->setValue( myAnimator->getMaxTime() );
422
423   connect(myMaxVal, SIGNAL( valueChanged(double)),
424           this, SLOT( onMaxValue(double) ));
425   aRangeLayout->addWidget(myMaxVal, 1, 3);
426
427   connect(myUseRangeChk, SIGNAL( toggled(bool)),
428           aMinLbl, SLOT( setEnabled(bool) ));
429   connect(myUseRangeChk, SIGNAL( toggled(bool)),
430           aMaxLbl, SLOT( setEnabled(bool) ));
431   connect(myUseRangeChk, SIGNAL( toggled(bool)),
432           this, SLOT( onRangeCheck(bool) ));
433
434   aMainLayout->addWidget(aRangeGrp);
435
436
437   QHBox* aPropFrame = new QHBox(this);
438   aPropFrame->setSpacing(5);
439
440   QVGroupBox* aNamesBox = new QVGroupBox("Fields",aPropFrame);
441   myFieldLst = new QListBox(aNamesBox);
442   QStringList aFieldNames;
443   // Find names of fields
444   for (int i = 0; i < theAnimator->getNbFields(); i++) {
445     _PTR(SObject) aSO = theAnimator->getFieldData(i).myField;
446     aFieldNames.append(VISU::getValue(aSO, "myName"));
447   }
448   myFieldLst->insertStringList(aFieldNames);
449   myFieldLst->setSelected(0, true);
450   connect( myFieldLst, SIGNAL( highlighted(int) ),
451            this, SLOT( onFieldChange(int) ) );
452
453
454   QVBox* aSetupBox = new QVBox(aPropFrame);
455   aSetupBox->setSpacing(5);
456
457   QVGroupBox* aPropBox = new QVGroupBox("Properties", aSetupBox);
458   //QVGroupBox* aPropBox = new QVGroupBox("Properties", aPropFrame);
459   myTypeCombo = new QComboBox(aPropBox);
460   connect( myTypeCombo, SIGNAL( activated(int) ),
461            this, SLOT( onTypeChanged(int) ) );
462
463   //  QPushButton* aBarBtn = new QPushButton("Scalar Bar...", aPropBox);
464   //connect( aBarBtn, SIGNAL( clicked() ),
465   //       this, SLOT( onScalarBarDlg() ) );
466
467   myPropBtn = new QPushButton("Properties...", aPropBox);
468   //  myPropBtn->setEnabled(theAnimator->getFieldData(0).myPrsType != VISU::TSCALARMAP);
469   connect( myPropBtn, SIGNAL( clicked() ),
470            this, SLOT( onPreferencesDlg() ) );
471
472   if (myAnimator->getNbFields() > 1) {
473     myArrangeBtn = new QPushButton("Arrange...", aSetupBox);
474     connect( myArrangeBtn, SIGNAL( clicked() ), this, SLOT( onArrangeDlg() ) );
475   }
476   onFieldChange(0);
477   aMainLayout->addWidget(aPropFrame);
478
479   QHBox* aBtnBox = new QHBox(this);
480   QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox->layout());
481   aBtnLayout->addStretch();
482
483   QPushButton* aCloseBtn = new QPushButton(tr("BUT_OK"), aBtnBox);
484   connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close()));
485
486   aMainLayout->addWidget(aBtnBox);
487 }
488
489 //************************************************************************
490 enum PrsComboItem {
491   TSCALARMAP_ITEM     = 0, // VISU::TSCALARMAP
492   TISOSURFACE_ITEM    = 1, // VISU::TISOSURFACE
493   TCUTPLANES_ITEM     = 2, // VISU::TCUTPLANES
494   TPLOT3D_ITEM        = 3, // VISU::TPLOT3D
495   TDEFORMEDSHAPE_ITEM = 4, // VISU::TDEFORMEDSHAPE
496   TVECTORS_ITEM       = 5, // VISU::TVECTORS
497   TSTREAMLINES_ITEM   = 6  // VISU::TSTREAMLINES
498 };
499
500 //************************************************************************
501 void SetupDlg::onFieldChange (int theIndex)
502 {
503   FieldData& aData = myAnimator->getFieldData(theIndex);
504   myTypeCombo->clear();
505   // ATTENTION: append items in the same order like it is done in the PrsComboItem enumeration
506   myTypeCombo->insertItem("Scalar Map");   // item 0
507   myTypeCombo->insertItem("Iso Surfaces"); // item 1
508   myTypeCombo->insertItem("Cut Planes");   // item 2
509   myTypeCombo->insertItem("Plot 3D");      // item 3
510
511   _PTR(SObject) aSObject = aData.myField;
512   long aNumComp = VISU::getValue(aSObject, "myNumComponent").toLong();
513   if (aNumComp > 1) {
514     myTypeCombo->insertItem("Deformed Shape"); // item 4
515     myTypeCombo->insertItem("Vectors");        // item 5
516     myTypeCombo->insertItem("Stream Lines");   // item 6
517   }
518   switch (aData.myPrsType) {
519   case VISU::TSCALARMAP: //Scalar Map
520     myTypeCombo->setCurrentItem(TSCALARMAP_ITEM);
521     break;
522   case VISU::TISOSURFACE: //Iso Surfaces
523     myTypeCombo->setCurrentItem(TISOSURFACE_ITEM);
524     break;
525   case VISU::TCUTPLANES: //Cut Planes
526     myTypeCombo->setCurrentItem(TCUTPLANES_ITEM);
527     break;
528   case VISU::TPLOT3D: //Plot 3D
529     myTypeCombo->setCurrentItem(TPLOT3D_ITEM);
530     break;
531   case VISU::TDEFORMEDSHAPE: //Deformed Shape
532     myTypeCombo->setCurrentItem(TDEFORMEDSHAPE_ITEM);
533     break;
534   case VISU::TVECTORS: //Vectors
535     myTypeCombo->setCurrentItem(TVECTORS_ITEM);
536     break;
537   case VISU::TSTREAMLINES: //Stream Lines
538     myTypeCombo->setCurrentItem(TSTREAMLINES_ITEM);
539     aData.myPrsType = VISU::TSTREAMLINES;
540     break;
541   }
542   //myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP);
543 }
544
545 //************************************************************************
546 void SetupDlg::onTypeChanged (int theIndex)
547 {
548   FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem());
549   switch (theIndex) {
550   case TSCALARMAP_ITEM: //Scalar Map
551     aData.myPrsType = VISU::TSCALARMAP;
552     break;
553   case TISOSURFACE_ITEM: //Iso Surfaces
554     aData.myPrsType = VISU::TISOSURFACE;
555     break;
556   case TCUTPLANES_ITEM: //Cut Planes
557     aData.myPrsType = VISU::TCUTPLANES;
558     break;
559   case TPLOT3D_ITEM: //Plot 3D
560     aData.myPrsType = VISU::TPLOT3D;
561     break;
562   case TDEFORMEDSHAPE_ITEM: //Deformed Shape
563     aData.myPrsType = VISU::TDEFORMEDSHAPE;
564     break;
565   case TVECTORS_ITEM: //Vectors
566     aData.myPrsType = VISU::TVECTORS;
567     break;
568   case TSTREAMLINES_ITEM: //Stream Lines
569     aData.myPrsType = VISU::TSTREAMLINES;
570     break;
571   }
572   myAnimator->clearData(aData);
573   //myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP);
574   //myAnimator->generatePresentations(myFieldLst->currentItem());
575 }
576
577 //************************************************************************
578 /*void SetupDlg::onScalarBarDlg() {
579   QApplication::setOverrideCursor( Qt::waitCursor );
580   FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem());
581   if (aData.myPrs == 0)
582     myAnimator->generatePresentations(myFieldLst->currentItem());
583   QApplication::restoreOverrideCursor();
584
585   VisuGUI_ScalarBarDlg* aScalarBarDlg = new VisuGUI_ScalarBarDlg();
586   aScalarBarDlg->initFromPrsObject(aData.myPrs[0]);
587   if (aScalarBarDlg->exec()) {
588     for (int i = 0; i < aData.myNbFrames; i++)
589       aScalarBarDlg->storeToPrsObject(aData.myPrs[i]);
590   }
591 }
592 */
593
594 //************************************************************************
595 void SetupDlg::onPreferencesDlg()
596 {
597   MESSAGE("SetupDlg::onPreferencesDlg() is not implemented");
598   SUIT_OverrideCursor c;
599   FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem());
600   if (aData.myPrs.empty())
601     myAnimator->generatePresentations(myFieldLst->currentItem());
602
603 // BUG VISU5725 : Compatibility gcc 2.95
604 // #define EDITPRS(TYPE, DLG) \
605 //     { \
606 //       DLG* aDlg = new DLG(); \
607 //       aDlg->initFromPrsObject(dynamic_cast<TYPE*>(aData.myPrs.at(0))); \
608 //       if (aDlg->exec()) { \
609 //      for (int i = 0; i < aData.myNbFrames; i++) \
610 //        aDlg->storeToPrsObject(dynamic_cast<TYPE*>(aData.myPrs.at(i))); \
611 //       } \
612 //       delete aDlg; \
613 //     }
614
615
616 #define EDITPRS(TYPE, DLG) {\
617         DLG* aDlg = new DLG (myModule);\
618         aDlg->initFromPrsObject(dynamic_cast<TYPE*>(aData.myPrs[0]));\
619         if (aDlg->exec())\
620         { \
621          for (int i = 0; i < aData.myNbFrames; i++)\
622           aDlg->storeToPrsObject(dynamic_cast<TYPE*>(aData.myPrs[i]));\
623         } \
624         delete aDlg;}
625
626   switch (myTypeCombo->currentItem()) {
627   case TSCALARMAP_ITEM: //Scalar Map
628     c.suspend();
629     EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
630     break;
631   case TISOSURFACE_ITEM: //Iso Surfaces
632     c.suspend();
633     EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
634     break;
635   case TCUTPLANES_ITEM: //Cut Planes
636     //    EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
637     {
638       c.suspend();
639       VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, true);
640       //_CS_PhB :operator [] .at      aDlg->initFromPrsObject(dynamic_cast<VISU::CutPlanes_i*>(aData.myPrs.at(0)));
641       aDlg->initFromPrsObject(dynamic_cast<VISU::CutPlanes_i*>(aData.myPrs[0]));
642
643       if (aDlg->exec()) {
644         for (int i = 0; i < aData.myNbFrames; i++)
645       //_CS_PhB:operator [] .at   aDlg->storeToPrsObject(dynamic_cast<VISU::CutPlanes_i*>(aData.myPrs.at(i)));
646           aDlg->storeToPrsObject(dynamic_cast<VISU::CutPlanes_i*>(aData.myPrs[i]));
647       }
648       delete aDlg;
649     }
650     break;
651   case TPLOT3D_ITEM: //Plot 3D
652     c.suspend();
653     EDITPRS(VISU::Plot3D_i, VisuGUI_Plot3DDlg);
654     break;
655   case TDEFORMEDSHAPE_ITEM: //Deformed Shape
656     c.suspend();
657     EDITPRS(VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg);
658     break;
659   case TVECTORS_ITEM: //Vectors
660     c.suspend();
661     EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
662     break;
663   case TSTREAMLINES_ITEM: //Stream Lines
664     c.suspend();
665     EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
666     break;
667   }
668 #undef EDITPRS
669 }
670
671
672 //************************************************************************
673 void SetupDlg::onArrangeDlg()
674 {
675   ArrangeDlg aDlg(this, myAnimator);
676   aDlg.exec();
677 }
678
679 //************************************************************************
680 void SetupDlg::onRangeCheck (bool theCheck)
681 {
682   for (int i = 0; i < myAnimator->getNbFields(); i++)
683     myAnimator->clearData(myAnimator->getFieldData(i));
684
685   myMinVal->setEnabled(theCheck);
686   myMaxVal->setEnabled(theCheck);
687
688   if (!theCheck)
689     myAnimator->setAnimationRange(0, 0);
690   else {
691     //    if (myMinVal->value() < myMaxVal->value())
692     myAnimator->setAnimationRange(myMinVal->value(), myMaxVal->value());
693 //     else if (myMinVal->value() > myMaxVal->value())
694 //       myAnimator->setAnimationRange(myMaxVal->value(), myMinVal->value());
695 //     else // equal case
696 //       myAnimator->setAnimationRange(0, 0);
697   }
698 }
699
700 //************************************************************************
701 void SetupDlg::onMinValue (double theVal)
702 {
703   if (theVal > myAnimator->getMaxRange()) {
704     myMinVal->setValue( myAnimator->getMinTime() );
705     myMinVal->setFocus();
706     return;
707   }
708   for (int i = 0; i < myAnimator->getNbFields(); i++)
709     myAnimator->clearData(myAnimator->getFieldData(i));
710   myAnimator->setAnimationRange(theVal, myAnimator->getMaxRange());
711 }
712
713 //************************************************************************
714 void SetupDlg::onMaxValue (double theVal)
715 {
716   if (theVal < myAnimator->getMinRange()) {
717     myMaxVal->setValue( myAnimator->getMaxTime() );
718     myMaxVal->setFocus();
719     return;
720   }
721   for (int i = 0; i < myAnimator->getNbFields(); i++)
722     myAnimator->clearData(myAnimator->getFieldData(i));
723   myAnimator->setAnimationRange(myAnimator->getMinRange(), theVal);
724 }
725
726 static const char * firstIco[] = {
727 "18 10 2 1",
728 "       g None",
729 ".      g #000000",
730 "         .     .  ",
731 "  ..    ..    ..  ",
732 "  ..   ...   ...  ",
733 "  ..  ....  ....  ",
734 "  .. ..... .....  ",
735 "  .. ..... .....  ",
736 "  ..  ....  ....  ",
737 "  ..   ...   ...  ",
738 "  ..    ..    ..  ",
739 "         .     .  "};
740
741
742 static const char * lastIco[] = {
743 "18 10 2 1",
744 "       g None",
745 ".      g #000000",
746 "  .     .         ",
747 "  ..    ..    ..  ",
748 "  ...   ...   ..  ",
749 "  ....  ....  ..  ",
750 "  ..... ..... ..  ",
751 "  ..... ..... ..  ",
752 "  ....  ....  ..  ",
753 "  ...   ...   ..  ",
754 "  ..    ..    ..  ",
755 "  .     .         "};
756
757
758 static const char * leftIco[] = {
759 "11 10 2 1",
760 "       g None",
761 ".      g #000000",
762 "    .     .",
763 "   ..    ..",
764 "  ...   ...",
765 " ....  ....",
766 "..... .....",
767 "..... .....",
768 " ....  ....",
769 "  ...   ...",
770 "   ..    ..",
771 "    .     ."};
772
773 static const char * playIco[] = {
774 "14 14 2 1",
775 "       g None",
776 ".      g #000000",
777 "              ",
778 "              ",
779 "  ..          ",
780 "  ....        ",
781 "  ......      ",
782 "  ........    ",
783 "  ..........  ",
784 "  ..........  ",
785 "  ........    ",
786 "  ......      ",
787 "  ....        ",
788 "  ..          ",
789 "              ",
790 "              "};
791
792 static QPixmap MYplayPixmap(playIco);
793
794
795 static const char * rightIco[] = {
796 "11 10 2 1",
797 "       g None",
798 ".      g #000000",
799 ".     .    ",
800 "..    ..   ",
801 "...   ...  ",
802 "....  .... ",
803 "..... .....",
804 "..... .....",
805 "....  .... ",
806 "...   ...  ",
807 "..    ..   ",
808 ".     .    "};
809
810
811 static const char * pauseIco[] = {
812 "14 14 2 1",
813 "       g None",
814 ".      g #000000",
815 "              ",
816 "              ",
817 "   ..    ..   ",
818 "   ..    ..   ",
819 "   ..    ..   ",
820 "   ..    ..   ",
821 "   ..    ..   ",
822 "   ..    ..   ",
823 "   ..    ..   ",
824 "   ..    ..   ",
825 "   ..    ..   ",
826 "   ..    ..   ",
827 "              ",
828 "              "};
829
830 static QPixmap MYpausePixmap(pauseIco);
831
832
833 VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Study) theStudy)
834      : QDialog(VISU::GetDesktop(theModule), "VisuGUI_TimeAnimationDlg", false, WStyle_Customize |
835                WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
836        myModule(theModule),
837        myStudy(theStudy)
838 {
839   setCaption("Animation");
840   setSizeGripEnabled( TRUE );
841   isClosing = false;
842
843   myAnimator = new VISU_TimeAnimation (theStudy);
844   myAnimator->setSpeed(1);
845   myAnimator->setViewer(VISU::GetViewWindow());
846   connect(myAnimator, SIGNAL(frameChanged(long, double)), this, SLOT(onExecution(long, double)));
847   connect(myAnimator, SIGNAL(stopped()),                  this, SLOT(onStop()));
848
849   QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6);
850   aMainLayout->setSpacing(5);
851
852   mySetupBtn = new QPushButton("Setup Animation...", this);
853   connect( mySetupBtn, SIGNAL( clicked() ),
854            this, SLOT( onSetupDlg() ) );
855   aMainLayout->addWidget(mySetupBtn);
856
857   myGenBtn = new QPushButton("Generate frames", this);
858   connect( myGenBtn, SIGNAL( clicked() ),
859            this, SLOT( createFrames() ) );
860   aMainLayout->addWidget(myGenBtn);
861
862   myPlayFrame = new QFrame(this);
863   myPlayFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
864   myPlayFrame->setLineWidth( 1 );
865
866
867   // --- Play controls ---
868   QGridLayout* TopLayout = new QGridLayout( myPlayFrame );
869   TopLayout->setSpacing( 6 );
870   TopLayout->setMargin( 11 );
871
872   myTimeLbl = new QLabel("0", myPlayFrame);
873   TopLayout->addMultiCellWidget(myTimeLbl, 0, 0, 0, 2, Qt::AlignHCenter);
874
875   mySlider = new QSlider(Qt::Horizontal, myPlayFrame);
876   mySlider->setMinValue(0);
877   mySlider->setMaxValue(3);
878   mySlider->setTickInterval(1);
879   //mySlider->setTickmarks(QSlider::Below);
880   mySlider->setTracking(false);
881   connect( mySlider, SIGNAL( valueChanged(int) ),
882            this, SLOT( onWindowChanged(int) ) );
883   TopLayout->addMultiCellWidget(mySlider, 1, 1, 0, 2);
884
885   myPlayBtn = new QToolButton(myPlayFrame);
886   myPlayBtn->setIconSet(MYplayPixmap);
887   myPlayBtn->setToggleButton(true);
888   connect( myPlayBtn, SIGNAL( clicked() ),
889            this, SLOT( onPlayPressed() ) );
890   TopLayout->addMultiCellWidget(myPlayBtn, 2, 2, 0, 1);
891
892   QToolButton* aBackBtn = new QToolButton(myPlayFrame);
893   aBackBtn->setIconSet(QPixmap(leftIco));
894   connect( aBackBtn, SIGNAL( clicked() ),
895            this, SLOT( onBackPressed() ) );
896   TopLayout->addWidget(aBackBtn, 3, 0);
897
898   QToolButton* aForvardBtn = new QToolButton(myPlayFrame);
899   aForvardBtn->setIconSet(QPixmap(rightIco));
900   connect( aForvardBtn, SIGNAL( clicked() ),
901            this, SLOT( onForvardPressed() ) );
902   TopLayout->addWidget(aForvardBtn, 3, 1);
903
904   QToolButton* aFirstBtn = new QToolButton(myPlayFrame);
905   aFirstBtn->setIconSet(QPixmap(firstIco));
906   connect( aFirstBtn, SIGNAL( clicked() ),
907            this, SLOT( onFirstPressed() ) );
908   TopLayout->addWidget(aFirstBtn, 4, 0);
909
910   QToolButton* aLastBtn = new QToolButton(myPlayFrame);
911   aLastBtn->setIconSet(QPixmap(lastIco));
912   connect( aLastBtn, SIGNAL( clicked() ),
913            this, SLOT( onLastPressed() ) );
914   TopLayout->addWidget(aLastBtn, 4, 1);
915
916   QLabel* aSpeedLbl = new QLabel("Speed", myPlayFrame);
917   TopLayout->addWidget(aSpeedLbl, 4, 2, Qt::AlignRight);
918
919   QLCDNumber* aSpeedNum  = new QLCDNumber( 2, myPlayFrame );
920   aSpeedNum->setSegmentStyle(QLCDNumber::Flat);
921   aSpeedNum->display(1);
922   TopLayout->addWidget(aSpeedNum, 4, 3);
923
924   QwtWheel* aWheel = new QwtWheel(myPlayFrame);
925   aWheel->setOrientation(Qt::Vertical);
926   aWheel->setRange(1, 99, 1);
927   connect( aWheel, SIGNAL(valueChanged(double)),
928            aSpeedNum, SLOT(display(double)) );
929   connect( aWheel, SIGNAL(valueChanged(double)),
930            this, SLOT(onSpeedChange(double)) );
931   TopLayout->addMultiCellWidget(aWheel, 1, 3, 3, 3, Qt::AlignRight);
932
933   QCheckBox* aCycleCheck = new QCheckBox("Cycled animation",myPlayFrame);
934   aCycleCheck->setChecked(myAnimator->isCycling());
935   connect(aCycleCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setCyclingSlot(bool)));
936   TopLayout->addMultiCellWidget(aCycleCheck, 5, 5, 0, 3);
937
938   QCheckBox* aPropCheck = new QCheckBox("Use proportional timing",myPlayFrame);
939   aPropCheck->setChecked(myAnimator->isProportional());
940   connect(aPropCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setProportionalSlot(bool)));
941   TopLayout->addMultiCellWidget(aPropCheck, 6, 6, 0, 3);
942
943   QGroupBox* aSaveBox = new QGroupBox( "Saving", myPlayFrame );
944   aSaveBox->setColumnLayout(0, Qt::Horizontal );
945   QGridLayout* aSaveLay = new QGridLayout(aSaveBox->layout());
946   aSaveLay->setSpacing( 5 );
947   aSaveLay->setMargin( 5 );
948
949   mySaveCheck = new QCheckBox("Save pictures to directory", aSaveBox);
950   aSaveLay->addMultiCellWidget(mySaveCheck, 0, 0, 0, 2);
951   connect(mySaveCheck, SIGNAL( toggled(bool)),
952           aWheel, SLOT( setDisabled(bool) ));
953
954   QLabel* aPathLbl = new QLabel("Path:", aSaveBox);
955   aPathLbl->setEnabled(false);
956   connect(mySaveCheck, SIGNAL( toggled(bool)),
957           aPathLbl, SLOT( setEnabled(bool) ));
958   aSaveLay->addWidget(aPathLbl, 1, 0);
959
960   myPathEdit = new QLineEdit(aSaveBox);
961   myPathEdit->setEnabled(false);
962   connect(mySaveCheck, SIGNAL( toggled(bool)),
963           myPathEdit, SLOT( setEnabled(bool) ));
964   aSaveLay->addWidget(myPathEdit, 1, 1);
965
966   QPushButton* aBrowseBtn = new QPushButton("Browse...", aSaveBox);
967   aBrowseBtn->setEnabled(false);
968   connect(mySaveCheck, SIGNAL( toggled(bool)),
969           aBrowseBtn, SLOT( setEnabled(bool) ));
970   connect(aBrowseBtn, SIGNAL( clicked()),
971           this, SLOT( onBrowse() ));
972   mySaveCheck->setChecked(false);
973   aSaveLay->addWidget(aBrowseBtn, 1, 2);
974
975   TopLayout->addMultiCellWidget(aSaveBox, 7, 7, 0, 3);
976
977   aMainLayout->addWidget(myPlayFrame);
978
979   QHBox* aPublishBox = new QHBox(this);
980   aPublishBox->setSpacing(5);
981
982   myPublishBtn = new QPushButton("Publish to study", aPublishBox);
983   connect(myPublishBtn, SIGNAL(clicked()), this, SLOT(publishToStudy()));
984
985   mySaveBtn = new QPushButton("Save Animation", aPublishBox);
986   mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
987   connect(mySaveBtn, SIGNAL(clicked()), this, SLOT(saveToStudy()));
988
989   aMainLayout->addWidget(aPublishBox);
990
991
992   QHBox* aBtnBox = new QHBox(this);
993   QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox->layout());
994   aBtnLayout->addStretch();
995
996   QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox);
997   connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close()));
998
999   SUIT_Study* aStudy = VISU::GetAppStudy(myModule);
1000   connect(aStudy, SIGNAL(destroyed()), this, SLOT(close()));
1001
1002   aMainLayout->addWidget(aBtnBox);
1003
1004   myPlayFrame->setEnabled(false);
1005 }
1006
1007 //************************************************************************
1008 VisuGUI_TimeAnimationDlg::~VisuGUI_TimeAnimationDlg()
1009 {
1010   delete myAnimator;
1011 }
1012
1013 //************************************************************************
1014 void VisuGUI_TimeAnimationDlg::onTypeChange (int index)
1015 {
1016   stopAnimation();
1017   myPropBtn->setEnabled(index != 0);
1018
1019   clearView();
1020   myPlayFrame->setEnabled(false);
1021 }
1022
1023 //************************************************************************
1024 void VisuGUI_TimeAnimationDlg::addField (_PTR(SObject) theSObject)
1025 {
1026   myPlayFrame->setEnabled(false);
1027   myAnimator->addField(VISU::GetSObject(theSObject));
1028 }
1029
1030 //************************************************************************
1031 void VisuGUI_TimeAnimationDlg::createFrames()
1032 {
1033   stopAnimation();
1034   SUIT_OverrideCursor c;
1035
1036   for (int i = 0; i < myAnimator->getNbFields(); i++) {
1037     if (myAnimator->getFieldData(i).myPrs.empty())
1038       myAnimator->generatePresentations(i);
1039   }
1040   if (myAnimator->getNbFrames() == 0) {
1041     myPlayFrame->setEnabled(false);
1042     c.suspend();
1043     SUIT_MessageBox::warn1(this,
1044                            tr("ERROR"),
1045                            tr("MSG_NO_ANIMATIONDATA"),
1046                            tr("&OK"));
1047     return;
1048   }
1049   mySlider->setMaxValue(myAnimator->getNbFrames()-1);
1050   myPlayFrame->setEnabled(true);
1051   if (!myAnimator->generateFrames()) {
1052     c.suspend();
1053     //myPlayFrame->setEnabled(false);
1054     SUIT_MessageBox::warn1(this,
1055                            tr("ERROR"),
1056                            myAnimator->getLastErrorMsg(),
1057                            tr("&OK"));
1058     return;
1059   }
1060   //myPlayFrame->setEnabled(true);
1061 }
1062
1063 //************************************************************************
1064 void VisuGUI_TimeAnimationDlg::onPlayPressed()
1065 {
1066   if (myPlayBtn->isOn() && (!myAnimator->running())) {
1067     myPlayBtn->setIconSet(MYpausePixmap);
1068     if (mySaveCheck->isChecked())
1069       myAnimator->dumpTo(myPathEdit->text());
1070     else
1071       myAnimator->dumpTo("");
1072     mySetupBtn->setEnabled(false);
1073     myGenBtn->setEnabled(false);
1074     myAnimator->startAnimation();
1075   } else {
1076     myPlayBtn->setIconSet(MYplayPixmap);
1077     myAnimator->stopAnimation();
1078     mySetupBtn->setEnabled(true);
1079     myGenBtn->setEnabled(true);
1080   }
1081 }
1082
1083 //************************************************************************
1084 void VisuGUI_TimeAnimationDlg::onBackPressed()
1085 {
1086   //stopAnimation();
1087   myAnimator->prevFrame();
1088 }
1089
1090 //************************************************************************
1091 void VisuGUI_TimeAnimationDlg::onForvardPressed()
1092 {
1093   myAnimator->nextFrame();
1094 }
1095
1096 //************************************************************************
1097 void VisuGUI_TimeAnimationDlg::onLastPressed()
1098 {
1099   myAnimator->lastFrame();
1100 }
1101
1102 //************************************************************************
1103 void VisuGUI_TimeAnimationDlg::onFirstPressed()
1104 {
1105   myAnimator->firstFrame();
1106 }
1107
1108 //************************************************************************
1109 void VisuGUI_TimeAnimationDlg::clearView()
1110 {
1111   myAnimator->clearView();
1112 }
1113
1114 //************************************************************************
1115 void VisuGUI_TimeAnimationDlg::closeEvent (QCloseEvent* theEvent)
1116 {
1117   myAnimator->stopAnimation();
1118   myAnimator->wait(500);
1119   if (myAnimator->running() && (! myAnimator->finished())) {
1120     isClosing = true;
1121     myEvent = theEvent;
1122   } else {
1123     QDialog::closeEvent(theEvent);
1124   }
1125 }
1126
1127 //************************************************************************
1128 void VisuGUI_TimeAnimationDlg::onWindowChanged (int index)
1129 {
1130   if (myAnimator->isRunning()) return;
1131   myAnimator->gotoFrame(index);
1132 }
1133
1134 //************************************************************************
1135 void VisuGUI_TimeAnimationDlg::onSpeedChange (double theSpeed)
1136 {
1137   myAnimator->setSpeed((int)theSpeed);
1138 }
1139
1140 //************************************************************************
1141 void VisuGUI_TimeAnimationDlg::stopAnimation()
1142 {
1143   myAnimator->stopAnimation();
1144   myPlayBtn->setOn(false);
1145   myPlayBtn->setIconSet(MYplayPixmap);
1146   mySetupBtn->setEnabled(true);
1147   myGenBtn->setEnabled(true);
1148 }
1149
1150 //************************************************************************
1151 void VisuGUI_TimeAnimationDlg::onExecution (long theNewFrame, double theTime)
1152 {
1153   myTimeLbl->setText(QString("%1").arg(theTime));
1154   mySlider->setValue(theNewFrame);
1155 }
1156
1157 //************************************************************************
1158 void VisuGUI_TimeAnimationDlg::onSetupDlg()
1159 {
1160   if (myAnimator->getNbFrames() > 0) myAnimator->firstFrame();
1161   SetupDlg* aDlg = new SetupDlg (myModule, myAnimator);
1162   aDlg->exec();
1163   myPlayFrame->setEnabled(false);
1164   delete aDlg;
1165 }
1166
1167 //************************************************************************
1168 void VisuGUI_TimeAnimationDlg::onBrowse()
1169 {
1170   QString aPath = SUIT_FileDlg::getExistingDirectory(this, "/","Select path");
1171   if (!aPath.isEmpty())
1172     myPathEdit->setText(aPath);
1173 }
1174
1175 //************************************************************************
1176 void VisuGUI_TimeAnimationDlg::onStop()
1177 {
1178   if (isClosing) {
1179     QDialog::closeEvent(myEvent);
1180   } else {
1181     myPlayBtn->setOn(false);
1182     myPlayBtn->setIconSet(MYplayPixmap);
1183     mySetupBtn->setEnabled(true);
1184     myGenBtn->setEnabled(true);
1185   }
1186 }
1187
1188 //************************************************************************
1189 void VisuGUI_TimeAnimationDlg::saveToStudy()
1190 {
1191   myAnimator->saveAnimation();
1192   myModule->updateObjBrowser( true );
1193 }
1194
1195 //************************************************************************
1196 void VisuGUI_TimeAnimationDlg::publishToStudy()
1197 {
1198   myAnimator->publishInStudy();
1199   myModule->updateObjBrowser( true );
1200   mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
1201 }
1202
1203 //************************************************************************
1204 void VisuGUI_TimeAnimationDlg::restoreFromStudy(_PTR(SObject) theAnimation)
1205 {
1206   myAnimator->restoreFromStudy(theAnimation);
1207   mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
1208 }