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