]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for bug PAL11537 : Create an animation given several med files (add consecutive...
authormkr <mkr@opencascade.com>
Tue, 31 Oct 2006 16:42:35 +0000 (16:42 +0000)
committermkr <mkr@opencascade.com>
Tue, 31 Oct 2006 16:42:35 +0000 (16:42 +0000)
idl/VISU_Gen.idl
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISUGUI/VisuGUI_TimeAnimation.h
src/VISU_I/VISU_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.h

index 2c18149d19e2f49cdacc1c563fb431d501027904..ab37563514fb36a75cda3a7bda4d4c92c27f9468 100644 (file)
@@ -1153,11 +1153,22 @@ module VISU {
    * of calculations are taken in one definite moment.
    */
   interface Animation : Base {
+    /*!
+   * This enumeration contains a set of available animation modes.
+   */
+    enum AnimationMode{ PARALLEL, /*!< parallel mode of animation. */
+                       CONSECUTIVE /*!< consecutive mode of animation. */
+    };
+    
     /*! Defines the field which will be used as a base for generation of the animation.
      * \param theObject The %SObject corresponding to the field.
      */
     boolean addField(in SALOMEDS::SObject theObject);
 
+    /*! Remove all fields from Animation object.
+     */
+    void clearFields();
+
     /*! Generates presentations on the basis of the field.
      * \param theFieldNum The number of the field, which will be used
      *                    as the basis for construction of the presentation.
@@ -1331,6 +1342,17 @@ module VISU {
     void restoreFromStudy(in SALOMEDS::SObject theSObj);
 
     boolean isSavedInStudy();
+    
+    /*!
+     * Sets the animation mode.
+     * \param theMode The value of this parameter is taken from the <VAR>AnimationMode</VAR> enumeration.
+     */
+    void setAnimationMode(in AnimationMode theMode);
+
+    /*!
+     * Gets the animation mode.
+     */
+    AnimationMode getAnimationMode();
   };
 
   /*! \brief Interface %Result
index 44bd3c3e9f0bacd5f913590b662b53aa49792501..125a1224dbfece0783b2c58d85502ce23a56bf9c 100644 (file)
@@ -53,7 +53,7 @@ msgid "ERR_CANT_CREATE_ACTOR"
 msgstr "Can't create actor for this presentation"
 
 msgid "ERR_CANT_CREATE_ANIMATION"
-msgstr "Can't create animation for these fields:\n number of time stamps is not the same!"
+msgstr "Can't create animation for these fields:\n number of time stamps or number of components is not the same!"
 
 # Preferences for VISU module (VisuGUI.cxx)
 
@@ -239,8 +239,11 @@ msgstr "Representation Toolbar"
 msgid "VisuGUI::MEN_SHOW_ANIMATION"
 msgstr "Show..."
 
-msgid "VisuGUI::MEN_ANIMATION"
-msgstr "Animation..."
+msgid "VisuGUI::MEN_PARALLEL_ANIMATION"
+msgstr "Parallel Animation..."
+
+msgid "VisuGUI::MEN_CONSECUTIVE_ANIMATION"
+msgstr "Consecutive Animation..."
 
 msgid "VisuGUI::MEN_CELL_COLOR"
 msgstr "Cell color"
index 082543c709521a819478a523b932fa4ea2387c7b..f1080c4d8e963008c7096bfa5447e2474aa93fc7 100644 (file)
@@ -1642,14 +1642,14 @@ OnSweep()
 
 void
 VisuGUI::
-OnTimeAnimation()
+OnTimeAnimation(int theMode)
 {
   if (!VISU::GetActiveViewWindow<SVTK_ViewWindow>(this))
     return;
 
   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
   VisuGUI_TimeAnimationDlg* aAnimationDlg =
-    new VisuGUI_TimeAnimationDlg (this, aCStudy);
+    new VisuGUI_TimeAnimationDlg (this, aCStudy, theMode);
 
   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
   SALOME_ListIO aListIO;
@@ -1670,6 +1670,20 @@ OnTimeAnimation()
   aAnimationDlg->show();
 }
 
+void
+VisuGUI::
+OnParallelTimeAnimation()
+{
+  OnTimeAnimation(0);
+}
+
+void
+VisuGUI::
+OnConsecutiveTimeAnimation()
+{
+  OnTimeAnimation(1);
+}
+
 //************************************************************************
 void
 VisuGUI::
@@ -2260,9 +2274,14 @@ createActions()
                 this, SLOT(OnSelectionInfo()));
 
   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
-  createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap),
-                tr("MEN_ANIMATION"), "", 0, aParent, false,
-                this, SLOT(OnTimeAnimation()));
+  createAction( VISU_PARALLELANIMATION, tr("MEN_PARALLEL_ANIMATION"), QIconSet(aPixmap),
+                tr("MEN_PARALLEL_ANIMATION"), "", 0, aParent, false,
+                this, SLOT(OnParallelTimeAnimation()));
+
+  aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
+  createAction( VISU_CONSECUTIVEANIMATION, tr("MEN_CONSECUTIVE_ANIMATION"), QIconSet(aPixmap),
+                tr("MEN_CONSECUTIVE_ANIMATION"), "", 0, aParent, false,
+                this, SLOT(OnConsecutiveTimeAnimation()));
 
   aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
   createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
@@ -2447,7 +2466,8 @@ createPopupMenus()
   mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
 
   mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
-  mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
+  mgr->insert( action( VISU_PARALLELANIMATION ), -1, -1, -1 );
+  mgr->insert( action( VISU_CONSECUTIVEANIMATION ), -1, -1, -1 );
 
   mgr->insert( separator(), -1, -1, -1 );
 
@@ -2620,7 +2640,13 @@ createPopupMenus()
   aRule += " and $type in {'VISU::TFIELD'}";
   aRule += " and nbTimeStamps>1";
   aRule += " and activeView in {'VTKViewer' 'VVTK'}";
-  mgr->setRule( action( VISU_ANIMATION ), aRule, true );
+  mgr->setRule( action( VISU_PARALLELANIMATION ), aRule, true );
+
+  aRule = "client='ObjectBrowser' and selcount>0";
+  aRule += " and $type in {'VISU::TFIELD'}";
+  aRule += " and nbTimeStamps>0";
+  aRule += " and activeView in {'VTKViewer' 'VVTK'}";
+  mgr->setRule( action( VISU_CONSECUTIVEANIMATION ), aRule, true );
 
   aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
   mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
index 8c71e4071a32f1fc2157b55e37117a0bf92e7fd0..e4f7fd6be050ae7fe1b32b8311ca23d4bea97b2a 100644 (file)
@@ -146,7 +146,8 @@ protected slots:
   void OnRename();
   void OnClippingPlanes();
   void OnSweep();
-  void OnTimeAnimation();
+  void OnParallelTimeAnimation();
+  void OnConsecutiveTimeAnimation();
   void OnShowAnimation();
 
   void OnCopyPresentation();
@@ -160,6 +161,8 @@ protected slots:
 protected:
   virtual LightApp_Selection* createSelection() const;
 
+  void OnTimeAnimation(int theMode);
+
 private:
   void createActions();
   void createMenus();
index 0eaa8676cf8ef30994cac14f492ebf8a4cd6e5a6..b7819da579f9832809b604579e8bf6fdd7777ef8 100644 (file)
@@ -96,7 +96,8 @@
 #define VISU_CREATE_TABLE           4063
 #define VISU_SWEEP                  4064
 #define VISU_SELECTION_INFO         4065
-#define VISU_ANIMATION              4066
+#define VISU_PARALLELANIMATION      4066
+#define VISU_CONSECUTIVEANIMATION   4067
 
 #define VISU_ERASE_ALL              4070
 #define VISU_GLOBAL_SELECTION       4071
index dd50ee2daa01f5d605cedd5cb8dd238b6970b533..1022a0a5aae3e5813f6473e30dc10ffa1feb7567 100644 (file)
@@ -485,7 +485,14 @@ SetupDlg::SetupDlg (QWidget* theParent,
 
   double aMaxTime = myAnimator->getMaxTime();
   double aMinTime = myAnimator->getMinTime();
-  double aStep = (aMaxTime - aMinTime) / (myAnimator->getFieldData(0).myNbTimes - 1);
+  double aStep;
+  if ( myAnimator->getAnimationMode() == 0 ) 
+    aStep = (aMaxTime - aMinTime) / (myAnimator->getFieldData(0).myNbTimes - 1);
+  else { // consecutive animation mode
+    std::pair<int,long> aLastFieldFrame(myAnimator->getNbFields() - 1,
+                                       myAnimator->getFieldData(myAnimator->getNbFields() - 1).myNbTimes - 1);
+    aStep = (aMaxTime - aMinTime) / myAnimator->getAbsoluteFrameNumber(aLastFieldFrame);
+  }
 
   QLabel* aMinLbl = new QLabel("From", aRangeGrp);
   aMinLbl->setEnabled(myUseRangeChk->isChecked());
@@ -535,15 +542,26 @@ SetupDlg::SetupDlg (QWidget* theParent,
   // Find names of fields
   for (int i = 0; i < myAnimator->getNbFields(); i++) {
     _PTR(SObject) aSO = myAnimator->getFieldData(i).myField;
-    aFieldNames.append(VISU::getValue(aSO, "myName"));
+    QString aFieldName(VISU::getValue(aSO, "myName"));
+    if ( myAnimator->getAnimationMode() == 0 )
+      aFieldNames.append(aFieldName);
+    else if ( myAnimator->getAnimationMode() == 1 ) {
+      QString aFileName(VISU::getValue(aSO->GetFather()->GetFather()->GetFather(),"myInitFileName"));
+      aFileName = aFileName.right(aFileName.length() - (aFileName.findRev("/") + 1));
+      aFieldNames.append(aFileName + QString(" : ") + aFieldName);
+    }
   }
   myFieldLst->insertStringList(aFieldNames);
-  myFieldLst->setSelected(0, true);
-  connect( myFieldLst, SIGNAL( highlighted(int) ),
-          this, SLOT( onFieldChange(int) ) );
-
-
-  QVBox* aSetupBox = new QVBox(aPropFrame);
+  
+  if ( myAnimator->getAnimationMode() == 0 ) {
+    myFieldLst->setSelected(0, true);
+    connect( myFieldLst, SIGNAL( highlighted(int) ),
+            this, SLOT( onFieldChange(int) ) );
+  }
+  else if ( myAnimator->getAnimationMode() == 1 )
+    myFieldLst->setSelectionMode(QListBox::NoSelection);
+  
+    QVBox* aSetupBox = new QVBox(aPropFrame);
   aSetupBox->setSpacing(5);
 
   QVGroupBox* aPropBox = new QVGroupBox("Properties", aSetupBox);
@@ -561,7 +579,7 @@ SetupDlg::SetupDlg (QWidget* theParent,
   connect( myPropBtn, SIGNAL( clicked() ),
           this, SLOT( onPreferencesDlg() ) );
 
-  if (myAnimator->getNbFields() > 1) {
+  if (myAnimator->getNbFields() > 1 && myAnimator->getAnimationMode() == 0) {
     myArrangeBtn = new QPushButton("Arrange...", aSetupBox);
     connect( myArrangeBtn, SIGNAL( clicked() ), this, SLOT( onArrangeDlg() ) );
   }
@@ -595,7 +613,6 @@ enum PrsComboItem {
 //------------------------------------------------------------------------
 void SetupDlg::onFieldChange (int theIndex)
 {
-  FieldData& aData = myAnimator->getFieldData(theIndex);
   myTypeCombo->clear();
   myTypeId2ComboId.clear();
   myComboId2TypeId.clear();
@@ -621,9 +638,40 @@ void SetupDlg::onFieldChange (int theIndex)
   myTypeId2ComboId[TPLOT3D_ITEM] = myComboId2TypeId.size();
   myComboId2TypeId.push_back(TPLOT3D_ITEM);;
 
-  _PTR(SObject) aSObject = aData.myField;
-  long aNumComp = VISU::getValue(aSObject, "myNumComponent").toLong();
-  if (aNumComp > 1) {
+  bool anEnableItems = false;
+  bool anEnableGP = false;
+  VISU::VISUType aPrsType;
+  if ( myAnimator->getAnimationMode() == 0 ) { // parallel animation mode
+    
+    FieldData& aData = myAnimator->getFieldData(theIndex);
+    _PTR(SObject) aSObject = aData.myField;
+    long aNumComp = VISU::getValue(aSObject, "myNumComponent").toLong();
+    anEnableItems = (aNumComp > 1);
+    
+    long anEntityId = VISU::getValue(aSObject, "myEntityId").toLong();
+    anEnableGP = (anEntityId == VISU::CELL);
+
+    aPrsType = aData.myPrsType;
+
+  }
+  else if ( myAnimator->getAnimationMode() == 1 ) { // consecutive animation mode
+    
+    for (int i = 0; i < myAnimator->getNbFields(); i++) {
+      _PTR(SObject) aSO = myAnimator->getFieldData(i).myField;
+      long aNumComp = VISU::getValue(aSO, "myNumComponent").toLong();
+      anEnableItems = (aNumComp > 1);
+     
+      long anEntityId = VISU::getValue(aSO, "myEntityId").toLong();
+      anEnableGP = (anEntityId == VISU::CELL);
+
+      if ( !anEnableItems && !anEnableGP ) break;
+    }
+
+    aPrsType = myAnimator->getFieldData(0).myPrsType;
+
+  }
+
+  if (anEnableItems) {
     myTypeCombo->insertItem("Deformed Shape"); // item 5
     myTypeId2ComboId[TDEFORMEDSHAPE_ITEM] = myComboId2TypeId.size();
     myComboId2TypeId.push_back(TDEFORMEDSHAPE_ITEM);;
@@ -641,14 +689,13 @@ void SetupDlg::onFieldChange (int theIndex)
     myComboId2TypeId.push_back(TSCALARMAPONDEFORMEDSHAPE_ITEM);;
   }
 
-  long anEntityId = VISU::getValue(aSObject, "myEntityId").toLong();
-  if(anEntityId == VISU::CELL){
+  if(anEnableGP){
     myTypeCombo->insertItem("Gauss Points");   // item 8
     myTypeId2ComboId[TGAUSSPOINTS_ITEM] = myComboId2TypeId.size();
     myComboId2TypeId.push_back(TGAUSSPOINTS_ITEM);;
   }
 
-  switch (aData.myPrsType) {
+  switch (aPrsType) {
   case VISU::TSCALARMAP: //Scalar Map
     myTypeCombo->setCurrentItem(myTypeId2ComboId[TSCALARMAP_ITEM]);
     break;
@@ -686,41 +733,50 @@ void SetupDlg::onFieldChange (int theIndex)
 //------------------------------------------------------------------------
 void SetupDlg::onTypeChanged (int theIndex)
 {
-  FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem());
   int aType = myComboId2TypeId[theIndex];
-  switch (aType) {
-  case TSCALARMAP_ITEM: //Scalar Map
-    aData.myPrsType = VISU::TSCALARMAP;
-    break;
-  case TISOSURFACE_ITEM: //Iso Surfaces
-    aData.myPrsType = VISU::TISOSURFACE;
-    break;
-  case TCUTPLANES_ITEM: //Cut Planes
-    aData.myPrsType = VISU::TCUTPLANES;
-    break;
-  case TCUTLINES_ITEM: //Cut Lines
-    aData.myPrsType = VISU::TCUTLINES;
-    break;
-  case TPLOT3D_ITEM: //Plot 3D
-    aData.myPrsType = VISU::TPLOT3D;
-    break;
-  case TDEFORMEDSHAPE_ITEM: //Deformed Shape
-    aData.myPrsType = VISU::TDEFORMEDSHAPE;
-    break;
-  case TSCALARMAPONDEFORMEDSHAPE_ITEM: //Scalar Map on Deformed Shape
-    aData.myPrsType = VISU::TSCALARMAPONDEFORMEDSHAPE;
-    break;
-  case TVECTORS_ITEM: //Vectors
-    aData.myPrsType = VISU::TVECTORS;
-    break;
-  case TSTREAMLINES_ITEM: //Stream Lines
-    aData.myPrsType = VISU::TSTREAMLINES;
-    break;
-  case TGAUSSPOINTS_ITEM: //Gauss Points
-    aData.myPrsType = VISU::TGAUSSPOINTS;
-    break;
+  
+  for (int i = 0; i < myAnimator->getNbFields(); i++) {
+    FieldData& aData = ( myAnimator->getAnimationMode() == 0 ) ?
+      myAnimator->getFieldData(myFieldLst->currentItem()) :
+      myAnimator->getFieldData(i);
+
+    switch (aType) {
+    case TSCALARMAP_ITEM: //Scalar Map
+      aData.myPrsType = VISU::TSCALARMAP;
+      break;
+    case TISOSURFACE_ITEM: //Iso Surfaces
+      aData.myPrsType = VISU::TISOSURFACE;
+      break;
+    case TCUTPLANES_ITEM: //Cut Planes
+      aData.myPrsType = VISU::TCUTPLANES;
+      break;
+    case TCUTLINES_ITEM: //Cut Lines
+      aData.myPrsType = VISU::TCUTLINES;
+      break;
+    case TPLOT3D_ITEM: //Plot 3D
+      aData.myPrsType = VISU::TPLOT3D;
+      break;
+    case TDEFORMEDSHAPE_ITEM: //Deformed Shape
+      aData.myPrsType = VISU::TDEFORMEDSHAPE;
+      break;
+    case TSCALARMAPONDEFORMEDSHAPE_ITEM: //Scalar Map on Deformed Shape
+      aData.myPrsType = VISU::TSCALARMAPONDEFORMEDSHAPE;
+      break;
+    case TVECTORS_ITEM: //Vectors
+      aData.myPrsType = VISU::TVECTORS;
+      break;
+    case TSTREAMLINES_ITEM: //Stream Lines
+      aData.myPrsType = VISU::TSTREAMLINES;
+      break;
+    case TGAUSSPOINTS_ITEM: //Gauss Points
+      aData.myPrsType = VISU::TGAUSSPOINTS;
+      break;
+    }
+    myAnimator->clearData(aData);
+
+    if ( myAnimator->getAnimationMode() == 0 ) // parallel animation mode
+      break;
   }
-  myAnimator->clearData(aData);
   //myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP);
   //myAnimator->generatePresentations(myFieldLst->currentItem());
 }
@@ -732,13 +788,21 @@ namespace
   template<class TPrs3d, class TDialog>
   void
   EditPrs(VisuGUI* theModule,
-         FieldData& theData)
+         FieldData& theData,
+         VISU_TimeAnimation* theAnimator)
   {
     TDialog* aDlg = new TDialog(theModule);
     aDlg->initFromPrsObject(dynamic_cast<TPrs3d*>(theData.myPrs[0]));
-    if (aDlg->exec())
+    if (aDlg->exec()) {
       for (int i = 0; i < theData.myNbFrames; i++)
        aDlg->storeToPrsObject(dynamic_cast<TPrs3d*>(theData.myPrs[i]));
+      if ( theAnimator->getAnimationMode() == 1 ) {
+       for (int i = 1; i < theAnimator->getNbFields(); i++) {
+         for (int j = 0; j < theAnimator->getFieldData(i).myNbFrames; j++)
+           aDlg->storeToPrsObject(dynamic_cast<TPrs3d*>(theAnimator->getFieldData(i).myPrs[j]));
+       }
+      }
+    }
     delete aDlg;
   }
 }
@@ -747,9 +811,17 @@ namespace
 void SetupDlg::onPreferencesDlg()
 {
   SUIT_OverrideCursor c;
-  FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem());
+
+  int id = ( myAnimator->getAnimationMode() == 0 ) ? myFieldLst->currentItem() : 0;
+  FieldData& aData = myAnimator->getFieldData(id);
   if (aData.myPrs.empty())
-    myAnimator->generatePresentations(myFieldLst->currentItem());
+    myAnimator->generatePresentations(id);
+
+  if ( myAnimator->getAnimationMode() == 1 ) {
+    for (int i = 0; i < myAnimator->getNbFields(); i++) {
+      if ( i != id && myAnimator->getFieldData(i).myPrs.empty() ) myAnimator->generatePresentations(i);
+    }
+  }
 
   if(!aData.myNbFrames || !aData.myPrs[0]){
     QApplication::restoreOverrideCursor();
@@ -764,27 +836,27 @@ void SetupDlg::onPreferencesDlg()
   switch (aType) {
   case TSCALARMAP_ITEM: //Scalar Map
     c.suspend();
-    EditPrs<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg>(myModule,aData);
+    EditPrs<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg>(myModule,aData,myAnimator);
     break;
   case TISOSURFACE_ITEM: //Iso Surfaces
     c.suspend();
-    EditPrs<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg>(myModule,aData);
+    EditPrs<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg>(myModule,aData,myAnimator);
     break;
   case TCUTPLANES_ITEM: //Cut Planes
     c.suspend();
-    EditPrs<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg>(myModule,aData);
+    EditPrs<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg>(myModule,aData,myAnimator);
     break;
   case TCUTLINES_ITEM: //Cut Lines
     c.suspend();
-    EditPrs<VISU::CutLines_i,VisuGUI_CutLinesDlg>(myModule,aData);
+    EditPrs<VISU::CutLines_i,VisuGUI_CutLinesDlg>(myModule,aData,myAnimator);
     break;
   case TPLOT3D_ITEM: //Plot 3D
     c.suspend();
-    EditPrs<VISU::Plot3D_i,VisuGUI_Plot3DDlg>(myModule,aData);
+    EditPrs<VISU::Plot3D_i,VisuGUI_Plot3DDlg>(myModule,aData,myAnimator);
     break;
   case TDEFORMEDSHAPE_ITEM: //Deformed Shape
     c.suspend();
-    EditPrs<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg>(myModule,aData);
+    EditPrs<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg>(myModule,aData,myAnimator);
     break;
   case TSCALARMAPONDEFORMEDSHAPE_ITEM: //Scalar Map on Deformed Shape
     c.suspend();
@@ -810,15 +882,15 @@ void SetupDlg::onPreferencesDlg()
     break;
   case TVECTORS_ITEM: //Vectors
     c.suspend();
-    EditPrs<VISU::Vectors_i,VisuGUI_VectorsDlg>(myModule,aData);
+    EditPrs<VISU::Vectors_i,VisuGUI_VectorsDlg>(myModule,aData,myAnimator);
     break;
   case TSTREAMLINES_ITEM: //Stream Lines
     c.suspend();
-    EditPrs<VISU::StreamLines_i,VisuGUI_StreamLinesDlg>(myModule,aData);
+    EditPrs<VISU::StreamLines_i,VisuGUI_StreamLinesDlg>(myModule,aData,myAnimator);
     break;
   case TGAUSSPOINTS_ITEM: //Gauss Points
     c.suspend();
-    EditPrs<VISU::GaussPoints_i,VisuGUI_GaussPointsDlg>(myModule,aData);
+    EditPrs<VISU::GaussPoints_i,VisuGUI_GaussPointsDlg>(myModule,aData,myAnimator);
     break;
   }
 }
@@ -985,7 +1057,7 @@ static const char * pauseIco[] = {
 static QPixmap MYpausePixmap(pauseIco);
 
 
-VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Study) theStudy) :
+VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Study) theStudy, int theMode) :
   QDialog(VISU::GetDesktop(theModule), 
          "VisuGUI_TimeAnimationDlg", 
          false, 
@@ -994,7 +1066,10 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Stu
   myStudy(theStudy),
   mySetupDlg(NULL)
 {
-  setCaption("Animation");
+  if ( theMode == 0 )
+    setCaption("Parallel Animation");
+  else if ( theMode == 1 )
+    setCaption("Consecutive Animation");
   setSizeGripEnabled( TRUE );
   isClosing = false;
 
@@ -1002,6 +1077,7 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Stu
   myAnimator->setViewer(VISU::GetActiveViewWindow<SVTK_ViewWindow>(theModule));
   connect(myAnimator, SIGNAL(frameChanged(long, double)), this, SLOT(onExecution(long, double)));
   connect(myAnimator, SIGNAL(stopped()),                 this, SLOT(onStop()));
+  myAnimator->setAnimationMode(theMode);
 
   QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6);
   aMainLayout->setSpacing(5);
@@ -1526,6 +1602,8 @@ void VisuGUI_TimeAnimationDlg::restoreFromStudy(_PTR(SObject) theAnimation)
 {
   myAnimator->restoreFromStudy(theAnimation);
   mySaveBtn->setEnabled(myAnimator->isSavedInStudy());
+  if ( myAnimator->getAnimationMode() == 1 ) 
+    setCaption("Consecutive Animation");
 }
 
 //------------------------------------------------------------------------
index 6caff7f696f09320770c304be88014903aa74ef9..a4005098a6b5580524a7c3cf0c2190aba8c7d351 100644 (file)
@@ -143,7 +143,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog
 {
     Q_OBJECT
  public:
-    VisuGUI_TimeAnimationDlg(VisuGUI* theModule, _PTR(Study) theStudy);
+    VisuGUI_TimeAnimationDlg(VisuGUI* theModule, _PTR(Study) theStudy, int theMode=0);
     ~VisuGUI_TimeAnimationDlg();
 
     bool addField(_PTR(SObject) theField);
index fa85ef875ecf9fc5a04537f22361eb8b12abb5d0..2e1b6b80863d3e27da01223269b7354b75e6040a 100644 (file)
@@ -96,6 +96,7 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
     connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) );
   }
 
+  myAnimationMode = 0;
   myTimeMinVal = 0;
   myTimeMaxVal = 0;
   myTimeMin = 0;
@@ -159,22 +160,47 @@ bool VISU_TimeAnimation::addField (_PTR(SObject) theField)
     return false;
 
   aNewData.myNbTimes = VISU::Storable::FindValue(aMap,"myNbTimeStamps").toLong();
-  if ( aNewData.myNbTimes < 2 )
-    return false;
 
-  if ( !myFieldsLst.isEmpty() && myFieldsLst.first().myNbTimes != aNewData.myNbTimes )
-    return false;
+  if ( myAnimationMode == 0 ) { // parallel animation mode
+    if ( aNewData.myNbTimes < 2 )
+      return false;
+    if ( !myFieldsLst.isEmpty() && myFieldsLst.first().myNbTimes != aNewData.myNbTimes )
+      return false;
+    if ( myFieldsLst.isEmpty() )
+       myFieldsAbsFrames.push_back(aNewData.myNbTimes);
+  }
+  else { // consecutive animation mode
+    if ( aNewData.myNbTimes < 1 )
+      return false;
+
+    long aNumCompCurr = VISU::Storable::FindValue(aMap, "myNumComponent").toLong();
+    if ( !myFieldsLst.isEmpty() ) {
+      VISU::Storable::TRestoringMap aFMap = getMapOfValue(myFieldsLst.first().myField);
+      long aNumComp = VISU::Storable::FindValue(aFMap, "myNumComponent").toLong();
+      if ( aNumCompCurr != aNumComp )
+       return false;
+    }
 
+    if ( !myFieldsLst.isEmpty() )
+      myFieldsAbsFrames.push_back(myFieldsAbsFrames.back() + aNewData.myNbTimes);
+    else
+      myFieldsAbsFrames.push_back(aNewData.myNbTimes);
+  }
+    
   myFieldsLst.append(aNewData);
-
+  
   //find Min/Max timestamps
-  if ((myTimeMin == 0) && (myTimeMax == 0)) {
-    _PTR(ChildIterator) anIter = myStudy->NewChildIterator(theField);
-    anIter->Next(); // First is reference on support
+  _PTR(ChildIterator) anIter = myStudy->NewChildIterator(theField);
+  anIter->Next(); // First is reference on support
+  if ( myFieldsLst.size() == 1 ) { // the first field
     myTimeMin = getTimeValue(anIter->Value());
-    for(; anIter->More(); anIter->Next()) {
+    myTimeMax = getTimeValue(anIter->Value());
+  }
+  for(; anIter->More(); anIter->Next()) {
+    if ( myTimeMin > getTimeValue(anIter->Value()) )
+      myTimeMin = getTimeValue(anIter->Value());
+    if ( myTimeMax < getTimeValue(anIter->Value()) )
       myTimeMax = getTimeValue(anIter->Value());
-    }
   }
   
   return true;
@@ -190,7 +216,7 @@ bool VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField)
 
 
 //------------------------------------------------------------------------
-void VISU_TimeAnimation::clearData(FieldData& theData) {
+void VISU_TimeAnimation::_clearData(FieldData& theData) {
   if (!myView) {
     MESSAGE("Viewer is not defined for animation");
     return;
@@ -216,6 +242,12 @@ void VISU_TimeAnimation::clearData(FieldData& theData) {
   myView->update();
 }
 
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::clearData(FieldData& theData) {
+  ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TimeAnimation,FieldData&>
+                   (this,&VISU_TimeAnimation::_clearData,theData));
+}
+
 namespace
 {
   //------------------------------------------------------------------------
@@ -314,7 +346,29 @@ namespace
     }
   }
 }
-  
+
+double getMinFieldsValue( QValueList<FieldData>& theFieldsLst )
+{
+  // for consecutive animation mode only
+  double aRes = theFieldsLst[0].myPrs[0]->GetMin();
+  for (int i = 1; i < theFieldsLst.count(); i++) {
+    if ( aRes > theFieldsLst[i].myPrs[0]->GetMin() )
+      aRes = theFieldsLst[i].myPrs[0]->GetMin();    
+  }
+  return aRes;
+}
+
+double getMaxFieldsValue( QValueList<FieldData>& theFieldsLst )
+{
+  // for consecutive animation mode only
+  double aRes = theFieldsLst[0].myPrs[0]->GetMax();
+  for (int i = 1; i < theFieldsLst.count(); i++) {
+    if ( aRes < theFieldsLst[i].myPrs[0]->GetMax() )
+      aRes = theFieldsLst[i].myPrs[0]->GetMax();    
+  }
+  return aRes;
+}
+
 void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) {
   FieldData& aData = myFieldsLst[theFieldNum];
 
@@ -415,6 +469,30 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) {
     MESSAGE("Not implemented for this presentation type: " << aData.myPrsType);
     return;
   }
+  
+  if ( myAnimationMode == 1 ) { // consecutive animation mode
+    if ( isRangeDefined() ) {
+      if ( myFieldsAbsFrames.size() == getNbFields() ) 
+       myFieldsAbsFrames.clear();
+      if ( theFieldNum > 0 )
+       myFieldsAbsFrames.push_back(myFieldsAbsFrames.back() + aData.myNbFrames);      
+      else
+       myFieldsAbsFrames.push_back(aData.myNbFrames);
+    }
+    if ((theFieldNum == getNbFields() - 1) && aData.myPrsType != VISU::TGAUSSPOINTS){
+      double aMin = getMinFieldsValue(myFieldsLst);
+      double aMax = getMaxFieldsValue(myFieldsLst);
+      for (int i = 0; i < getNbFields(); i++)
+       for(long aFrameId = 0; aFrameId < myFieldsLst[i].myNbFrames; aFrameId++)
+         if (aData.myPrsType == VISU::TISOSURFACE) {
+           if (VISU::IsoSurfaces_i* aPrs = dynamic_cast<VISU::IsoSurfaces_i*>(myFieldsLst[i].myPrs[aFrameId]))
+           aPrs->SetSubRange(aMin, aMax);
+         }
+         else
+           if (VISU::ScalarMap_i* aPrs = dynamic_cast<VISU::ScalarMap_i*>(myFieldsLst[i].myPrs[aFrameId]))
+             aPrs->SetRange(aMin, aMax);
+    }
+  }
 }
 
 
@@ -439,7 +517,8 @@ CORBA::Boolean VISU_TimeAnimation::_generateFrames() {
        aData.myPrs[j]->SetOffset(aData.myOffset);
        aActor = aData.myPrs[j]->CreateActor();
        myView->AddActor(aActor);
-       if(j == 0)
+       bool condition = ( myAnimationMode == 0 ) ? (j == 0) : (j == 0 && i == 0);
+       if(condition)
          aActor->VisibilityOn();
        else
          aActor->VisibilityOff();
@@ -562,19 +641,45 @@ void VISU_TimeAnimation::_nextFrame() {
     return;
   }
   stopAnimation();
-  if (myFrame < (myFieldsLst[0].myNbFrames-1)) {
+  if (myFrame < getNbFrames() - 1 ) { //(myFieldsLst[0].myNbFrames-1)) {
     int i;
-    for (i = 0; i < getNbFields(); i++)
-      if (myFieldsLst[i].myActors[myFrame] != 0)
-       visibilityOff(i, myFrame);
+    std::pair<int,long> aPair;
+    int aFieldId;
+    long aFrameId;
+
+    if ( myAnimationMode == 0 ) { // parallel animation mode
+      for (i = 0; i < getNbFields(); i++)
+       if (myFieldsLst[i].myActors[myFrame] != 0)
+         visibilityOff(i, myFrame);
+    }
+    else { //consecutive animation mode
+      aPair = getRelativeFrameNumber(myFrame);
+      aFieldId = aPair.first;
+      aFrameId = aPair.second;
+      if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
+       visibilityOff(aFieldId, aFrameId);
+    }
 
     myFrame++;
-    for (i = 0; i < getNbFields(); i++)
-      if (myFieldsLst[i].myActors[myFrame] != 0)
-       myFieldsLst[i].myActors[myFrame]->VisibilityOn();
 
-    ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
+    if ( myAnimationMode == 0 ) { // parallel animation mode
+      for (i = 0; i < getNbFields(); i++)
+       if (myFieldsLst[i].myActors[myFrame] != 0)
+         myFieldsLst[i].myActors[myFrame]->VisibilityOn();
+
+      ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                               myFrame, myFieldsLst[0].myTiming[myFrame]));
+    }
+    else { //consecutive animation mode
+      aPair = getRelativeFrameNumber(myFrame);
+      aFieldId = aPair.first;
+      aFrameId = aPair.second;
+      if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
+       myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
+
+      ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                               myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
+    }
     myView->Repaint();
   }
 }
@@ -595,17 +700,43 @@ void VISU_TimeAnimation::_prevFrame() {
   stopAnimation();
   if (myFrame > 0) {
     int i;
-    for (i = 0; i < getNbFields(); i++)
-      if (myFieldsLst[i].myActors[myFrame] != 0)
-       visibilityOff(i, myFrame);
+    std::pair<int,long> aPair;
+    int aFieldId;
+    long aFrameId;
+
+    if ( myAnimationMode == 0 ) { // parallel animation mode
+      for (i = 0; i < getNbFields(); i++)
+       if (myFieldsLst[i].myActors[myFrame] != 0)
+         visibilityOff(i, myFrame);
+    }
+    else { //consecutive animation mode
+      aPair = getRelativeFrameNumber(myFrame);
+      aFieldId = aPair.first;
+      aFrameId = aPair.second;
+      if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
+         visibilityOff(aFieldId, aFrameId);
+    }
 
     myFrame--;
-    for (i = 0; i < getNbFields(); i++)
-      if (myFieldsLst[i].myActors[myFrame] != 0)
-       myFieldsLst[i].myActors[myFrame]->VisibilityOn();
 
-    ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
+    if ( myAnimationMode == 0 ) { // parallel animation mode
+      for (i = 0; i < getNbFields(); i++)
+       if (myFieldsLst[i].myActors[myFrame] != 0)
+         myFieldsLst[i].myActors[myFrame]->VisibilityOn();
+
+      ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                               myFrame, myFieldsLst[0].myTiming[myFrame]));
+    }
+    else { //consecutive animation mode
+      aPair = getRelativeFrameNumber(myFrame);
+      aFieldId = aPair.first;
+      aFrameId = aPair.second;
+      if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
+         myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
+
+      ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                               myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
+    }
     myView->Repaint();
   }
 }
@@ -625,15 +756,33 @@ void VISU_TimeAnimation::_firstFrame() {
   }
   stopAnimation();
   int i;
-  for (i = 0; i < getNbFields(); i++)
-    if(!myFieldsLst[i].myActors.empty())
-      if (myFieldsLst[i].myActors[myFrame] != 0)
-       visibilityOff(i, myFrame);
+  if ( myAnimationMode == 0 ) { // parallel animation mode
+    for (i = 0; i < getNbFields(); i++)
+      if(!myFieldsLst[i].myActors.empty())
+       if (myFieldsLst[i].myActors[myFrame] != 0)
+         visibilityOff(i, myFrame);
+    }
+  else { //consecutive animation mode
+    std::pair<int,long> aPair = getRelativeFrameNumber(myFrame);
+    int aFieldId = aPair.first;
+    long aFrameId = aPair.second;
+    if(!myFieldsLst[aFieldId].myActors.empty())
+      if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
+       visibilityOff(aFieldId, aFrameId);
+  }
   myFrame = 0;
-  for (i = 0; i < getNbFields(); i++)
+
+  int imax;
+  if ( myAnimationMode == 0 ) // parallel animation mode 
+    imax = getNbFields();
+  else //consecutive animation mode
+    imax = 1;
+
+  for (i = 0; i < imax; i++)
     if(!myFieldsLst[i].myActors.empty())
       if (myFieldsLst[i].myActors[myFrame] != 0)
        myFieldsLst[i].myActors[myFrame]->VisibilityOn();
+
   if(!myFieldsLst[0].myTiming.empty()){
     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
                                                                              myFrame, myFieldsLst[0].myTiming[myFrame]));
@@ -656,17 +805,44 @@ void VISU_TimeAnimation::_lastFrame() {
   }
   stopAnimation();
   int i;
-  for (i = 0; i < getNbFields(); i++)
-   if (myFieldsLst[i].myActors[myFrame] != 0)
-     visibilityOff(i, myFrame);
+  std::pair<int,long> aPair;
+  int aFieldId;
+  long aFrameId;
 
-  myFrame = myFieldsLst[0].myNbFrames-1;
-  for (i = 0; i < getNbFields(); i++)
-    if (myFieldsLst[i].myActors[myFrame] != 0)
-      myFieldsLst[i].myActors[myFrame]->VisibilityOn();
+  if ( myAnimationMode == 0 ) { // parallel animation mode
+    for (i = 0; i < getNbFields(); i++)
+      if (myFieldsLst[i].myActors[myFrame] != 0)
+       visibilityOff(i, myFrame);
+  }
+  else { //consecutive animation mode
+    aPair = getRelativeFrameNumber(myFrame);
+    aFieldId = aPair.first;
+    aFrameId = aPair.second;
+    if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
+      visibilityOff(aFieldId, aFrameId);
+  }
+
+  myFrame = getNbFrames() - 1; //myFieldsLst[0].myNbFrames-1;
+
+  if ( myAnimationMode == 0 ) { // parallel animation mode
+    for (i = 0; i < getNbFields(); i++)
+      if (myFieldsLst[i].myActors[myFrame] != 0)
+       myFieldsLst[i].myActors[myFrame]->VisibilityOn();
+    
+    ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
+  }
+  else { //consecutive animation mode
+    aPair = getRelativeFrameNumber(myFrame);
+    aFieldId = aPair.first;
+    aFrameId = aPair.second;
+    if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
+       myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
+
+    ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                             myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
+  }
 
-  ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                           myFrame, myFieldsLst[0].myTiming[myFrame]));
   myView->Repaint();
 }
 
@@ -689,17 +865,44 @@ void VISU_TimeAnimation::_gotoFrame(CORBA::Long theFrame) {
     return;
   stopAnimation();
   int i;
-  for (i = 0; i < getNbFields(); i++)
-    if (myFieldsLst[i].myActors[myFrame] != 0)
-      visibilityOff(i, myFrame);
+  std::pair<int,long> aPair;
+  int aFieldId;
+  long aFrameId;
+  
+  if ( myAnimationMode == 0 ) { // parallel animation mode
+    for (i = 0; i < getNbFields(); i++)
+      if (myFieldsLst[i].myActors[myFrame] != 0)
+       visibilityOff(i, myFrame);
+  }
+  else { //consecutive animation mode
+    aPair = getRelativeFrameNumber(myFrame);
+    aFieldId = aPair.first;
+    aFrameId = aPair.second;
+    if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
+       visibilityOff(aFieldId, aFrameId);
+  }
 
   myFrame = theFrame;
-  for (i = 0; i < getNbFields(); i++)
-    if (myFieldsLst[i].myActors[myFrame] != 0)
-      myFieldsLst[i].myActors[myFrame]->VisibilityOn();
 
-  ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
-                                                                           myFrame, myFieldsLst[0].myTiming[myFrame]));
+  if ( myAnimationMode == 0 ) { // parallel animation mode
+    for (i = 0; i < getNbFields(); i++)
+      if (myFieldsLst[i].myActors[myFrame] != 0)
+       myFieldsLst[i].myActors[myFrame]->VisibilityOn();
+
+    ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                             myFrame, myFieldsLst[0].myTiming[myFrame]));
+  }
+  else { //consecutive animation mode
+    aPair = getRelativeFrameNumber(myFrame);
+    aFieldId = aPair.first;
+    aFrameId = aPair.second;
+    if (myFieldsLst[aFieldId].myActors[aFrameId] != 0)
+       myFieldsLst[aFieldId].myActors[aFrameId]->VisibilityOn();
+
+    ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                             myFrame, myFieldsLst[aFieldId].myTiming[aFrameId]));
+  }
+
   myView->Repaint();
 }
 
@@ -734,26 +937,67 @@ VISU::ColoredPrs3d_ptr VISU_TimeAnimation::getPresentation(CORBA::Long theField,
 
 //------------------------------------------------------------------------
 CORBA::Long VISU_TimeAnimation::getNbFrames() {
-  return (getNbFields() > 0)? myFieldsLst[0].myNbFrames : 0;
+  if ( myAnimationMode == 0 ) // parallel animation mode
+    return (getNbFields() > 0)? myFieldsLst[0].myNbFrames : 0;
+  else //consecutive animation mode
+    return (getNbFields() > 0) ? myFieldsAbsFrames[myFieldsAbsFrames.size()-1] : 0;
 }
 
+//------------------------------------------------------------------------
+long VISU_TimeAnimation::getAbsoluteFrameNumber(std::pair<int,long> theFieldTimeStamp)
+{
+  long aRes = -1;
+  if ( getNbFields() > 0 ) {
+    int aFieldId = theFieldTimeStamp.first;
+    long aFrameNum = theFieldTimeStamp.second + 1;
+    if ( myAnimationMode == 0 ) { // parallel animation mode
+      if ( aFrameNum <= myFieldsAbsFrames[0] )
+        aRes = aFrameNum;
+    }
+    else { //consecutive animation mode
+      if ( aFieldId == 0 && aFrameNum <= myFieldsAbsFrames[aFieldId] )
+       aRes = aFrameNum;
+      else if ( aFieldId && aFrameNum <= myFieldsAbsFrames[aFieldId] - myFieldsAbsFrames[aFieldId-1] )
+       aRes = myFieldsAbsFrames[aFieldId-1] + aFrameNum;
+    }
+  }
+  return aRes - 1;
+}
 
 //------------------------------------------------------------------------
-void VISU_TimeAnimation::run()
-{
-  if (!myView) {
-    MESSAGE("Viewer is not defined for animation");
-    return;
+std::pair<int,long> VISU_TimeAnimation::getRelativeFrameNumber(long theFrame)
+{
+  std::pair<int,long> aRes;
+  if ( getNbFields() > 0 && theFrame < getNbFrames() ) {
+    theFrame = theFrame + 1;
+    if ( myAnimationMode == 0 ) { // parallel animation mode
+      aRes.first = 0;
+      aRes.second = theFrame - 1;
+    }
+    else { //consecutive animation mode
+      for (int i = 0, iEnd = myFieldsAbsFrames.size(); i < iEnd; i++)
+       if ( myFieldsAbsFrames[i] >= theFrame ) {
+         aRes.first = i;
+         if ( i == 0 )
+           aRes.second = theFrame - 1;
+         else
+           aRes.second = theFrame-myFieldsAbsFrames[i-1] - 1;
+         break;
+       }
+    }
   }
+  return aRes;
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList<int>& theIndexList )
+{
   double k = 1;
-  bool   isDumping = !myDumpPath.isEmpty();
   double aOneVal = 1;
   if (myFieldsLst[0].myNbFrames > 2)
-    aOneVal = myFieldsLst[0].myTiming[1] - myFieldsLst[0].myTiming[0];
-  myFileIndex = 0;
+    aOneVal = ( myTimeMax - myTimeMin ) / getNbFrames();
   int aNbFiles = 0;
-  QValueList<int> anIndexList;
-
+  
   while (myIsActive) {
     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
                                                                              myFrame, myFieldsLst[0].myTiming[myFrame]));
@@ -795,8 +1039,8 @@ void VISU_TimeAnimation::run()
       }
     }
     int delay = (int)(1000. * k / mySpeed);
-    isDumping = !myDumpPath.isEmpty();
-    if (delay < 1 && isDumping) {
+    theIsDumping = !myDumpPath.isEmpty();
+    if (delay < 1 && theIsDumping) {
       // We must unlock mutex for some time before grabbing to allow view updating
       delay = 1;
     }
@@ -806,7 +1050,7 @@ void VISU_TimeAnimation::run()
       return;
     }
 
-    if (isDumping) {
+    if (theIsDumping) {
       // We must unlock mutex for some time before grabbing to allow view updating
       msleep(delay);
       if (!myIsActive) { // this check was taken from WP_DEB branch
@@ -815,58 +1059,7 @@ void VISU_TimeAnimation::run()
       }
       if(!(myFieldsLst[0].myField)) // break, if field was deleted.
        break;
-      if (myDumpFormat.compare("AVI") != 0) {
-       QString aFile(myDumpPath);
-       QString aName = QString("%1").arg(myFieldsLst[0].myTiming[myFrame]);
-       int aPos = -1;
-       while ((aPos = aName.find(".")) > -1 )
-         aName.replace(aPos, 1, "_");
-       aFile += aName;
-       aFile += ".";
-       aFile += myDumpFormat.lower();
-       ProcessEvent(new TMemFun2ArgEvent<SVTK_ViewWindow,bool,const QString&,const QString&>
-                    (myView,&SVTK_ViewWindow::dumpViewToFormat,aFile,myDumpFormat));
-      } else {
-       QFileInfo aFileInfo(myDumpPath);
-       QString aDirPath = aFileInfo.dirPath(true);
-       QString aBaseName = aFileInfo.fileName();
-
-       switch (myFrame) {
-       case 0: 
-         break;
-       case 1:
-         myFileIndex += 5;
-         break;
-       default:
-         if (myProportional) {
-           double p = (myFieldsLst[0].myTiming[myFrame] -
-                       myFieldsLst[0].myTiming[myFrame-1]) / aOneVal;
-           myFileIndex += (long) (5*p);
-         } else {
-           myFileIndex += 5;
-         }
-       }
-
-       QString aFile = aDirPath + QDir::separator() + aBaseName;
-       aFile += "_";
-       aFile += QString("%1").arg(myFileIndex).rightJustify(8, '0');
-       aFile += ".jpeg";
-
-       /* check image size is divisable 16
-       myView->dumpViewToFormat(aFile,"JPEG");
-       */
-       SUIT_ViewWindow* aView = myView;
-       QImage img = ProcessEvent(new TMemFunEvent<SUIT_ViewWindow,QImage>(aView,&SUIT_ViewWindow::dumpView));
-       if (!img.isNull()) {
-         int width = img.width(); width = (width/16)*16;
-         int height = img.height(); height = (height/16)*16;
-         QImage copy = img.copy(0, 0, width, height);
-         if (copy.save(aFile, "JPEG")) {
-           anIndexList.append(myFileIndex);
-           aNbFiles++;
-         }
-       }
-      }
+      saveImages( 0, aOneVal, aNbFiles, theIndexList );
     }
 
     if (!myIsActive) break;
@@ -881,6 +1074,192 @@ void VISU_TimeAnimation::run()
        myFrame = 0;
     }
   }
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::consecutiveAnimation( bool& theIsDumping, QValueList<int>& theIndexList )
+{
+  if ( myFrame >= getNbFrames() - 1 ) 
+    return;
+
+  double k = 1;
+  double aOneVal = 1;
+  if (myFieldsLst[0].myNbFrames > 2)
+    aOneVal = ( myTimeMax - myTimeMin ) / getNbFrames();
+  int aNbFiles = 0;
+  long aFrame = myFrame;
+
+  while (myIsActive) {
+
+    for (int aFieldId = 0; (aFieldId < getNbFields()) && (myFieldsLst[aFieldId].myField); aFieldId++) {
+
+      FieldData& aData = myFieldsLst[aFieldId];
+      while (aFrame < aData.myNbFrames) {
+      
+       ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(this, &VISU_TimeAnimation::_emitFrameChanged,
+                                                                                 myFrame, myFieldsLst[aFieldId].myTiming[aFrame]));
+    
+       if (aFrame > 0) {
+         if (aData.myActors[aFrame-1] != 0)
+           visibilityOff(aFieldId, aFrame-1);
+       } else if ( myFrame > 0) {
+         if (myFieldsLst[aFieldId-1].myActors[myFieldsLst[aFieldId-1].myNbFrames-1] != 0)
+           visibilityOff(aFieldId-1, myFieldsLst[aFieldId-1].myNbFrames-1);
+       } else if ( myCycling ) {
+         if (myFieldsLst[getNbFields()-1].myActors[myFieldsLst[getNbFields()-1].myNbFrames-1] != 0)
+           visibilityOff(getNbFields()-1, myFieldsLst[getNbFields()-1].myNbFrames-1);
+       } else {
+         if (aData.myActors[aData.myNbFrames-1] != 0)
+           visibilityOff(aFieldId, aData.myNbFrames-1);
+       }
+       if (aData.myActors[aFrame] != 0) {
+         ProcessVoidEvent(new TVoidMemFunEvent<VISU_Actor>(aData.myActors[aFrame],
+                                                           &VISU_Actor::VisibilityOn));
+       }
+
+       bool repainArg = false;
+       ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
+                                                                       &SVTK_ViewWindow::Repaint,
+                                                                       repainArg));
+
+       k = 1;
+       if (myProportional) {
+         switch (aFrame) {
+         case 0:
+           break;
+         case 1:
+           if (myFieldsLst[0].myNbFrames > 2)
+             k = (myFieldsLst[0].myTiming[aFrame+1] -
+                  myFieldsLst[0].myTiming[aFrame]) / aOneVal;
+           break;
+         default:
+           if (aFrame < (myFieldsLst[0].myNbFrames - 1))
+             k = (myFieldsLst[0].myTiming[aFrame+1] -
+                  myFieldsLst[0].myTiming[aFrame]) / aOneVal;
+         }
+       }
+       int delay = (int)(1000. * k / mySpeed);
+       theIsDumping = !myDumpPath.isEmpty();
+       if (delay < 1 && theIsDumping) {
+         // We must unlock mutex for some time before grabbing to allow view updating
+         delay = 1;
+       }
+       msleep(delay);
+       if (!myIsActive) {
+         ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>(this,&VISU_TimeAnimation::_emitStopped));
+         return;
+       }
+
+       if (theIsDumping) {
+         // We must unlock mutex for some time before grabbing to allow view updating
+         msleep(delay);
+         if (!myIsActive) { // this check was taken from WP_DEB branch
+           ProcessVoidEvent(new TVoidMemFunEvent<VISU_TimeAnimation>(this,&VISU_TimeAnimation::_emitStopped));
+           return;
+         }
+
+         if(!(myFieldsLst[aFieldId].myField)) // break, if field was deleted.
+           break;
+
+         saveImages( aFieldId, aOneVal, aNbFiles, theIndexList );
+       }
+       
+       if (!myIsActive) break;
+       
+       aFrame++;
+       myFrame++;
+      }
+
+      aFrame = 0;
+    }
+
+    if (!myCycling) {
+      myIsActive = false;
+      myFrame--;
+      break;
+    } else {
+      myFrame = 0;
+      aFrame = myFrame;
+    }
+  }
+
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::saveImages( int theFieldId, 
+                                    double& theOneVal, int& theNbFiles, 
+                                    QValueList<int>& theIndexList )
+{
+  if (myDumpFormat.compare("AVI") != 0) {
+    QString aFile(myDumpPath);
+    QString aName = QString("%1").arg(myFieldsLst[theFieldId].myTiming[myFrame]);
+    int aPos = -1;
+    while ((aPos = aName.find(".")) > -1 )
+      aName.replace(aPos, 1, "_");
+    aFile += aName;
+    aFile += ".";
+    aFile += myDumpFormat.lower();
+    ProcessEvent(new TMemFun2ArgEvent<SVTK_ViewWindow,bool,const QString&,const QString&>
+                (myView,&SVTK_ViewWindow::dumpViewToFormat,aFile,myDumpFormat));
+  } else {
+    QFileInfo aFileInfo(myDumpPath);
+    QString aDirPath = aFileInfo.dirPath(true);
+    QString aBaseName = aFileInfo.fileName();
+    
+    switch (myFrame) {
+    case 0: 
+      break;
+    case 1:
+      myFileIndex += 5;
+      break;
+    default:
+      if (myProportional) {
+       double p = (myFieldsLst[0].myTiming[myFrame] -
+                   myFieldsLst[0].myTiming[myFrame-1]) / theOneVal;
+       myFileIndex += (long) (5*p);
+      } else {
+       myFileIndex += 5;
+      }
+    }
+    
+    QString aFile = aDirPath + QDir::separator() + aBaseName;
+    aFile += "_";
+    aFile += QString("%1").arg(myFileIndex).rightJustify(8, '0');
+    aFile += ".jpeg";
+    
+    /* check image size is divisable 16
+       myView->dumpViewToFormat(aFile,"JPEG");
+    */
+    SUIT_ViewWindow* aView = myView;
+    QImage img = ProcessEvent(new TMemFunEvent<SUIT_ViewWindow,QImage>(aView,&SUIT_ViewWindow::dumpView));
+    if (!img.isNull()) {
+      int width = img.width(); width = (width/16)*16;
+      int height = img.height(); height = (height/16)*16;
+      QImage copy = img.copy(0, 0, width, height);
+      if (copy.save(aFile, "JPEG")) {
+       theIndexList.append(myFileIndex);
+       theNbFiles++;
+      }
+    }
+  }
+}
+
+//------------------------------------------------------------------------
+void VISU_TimeAnimation::run()
+{
+  if (!myView) {
+    MESSAGE("Viewer is not defined for animation");
+    return;
+  }
+
+  bool isDumping = !myDumpPath.isEmpty();
+  myFileIndex = 0;
+  QValueList<int> anIndexList;
+
+  if ( myAnimationMode == 0 ) // parallel animation mode
+    parallelAnimation( isDumping, anIndexList );
+  else //consecutive animation mode
+    consecutiveAnimation( isDumping, anIndexList );
 
   // make AVI file if need
   if (isDumping && myDumpFormat.compare("AVI") == 0) {
@@ -1074,8 +1453,8 @@ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy()
   std::string aSComponentEntry = aSComponent->GetID();
 
   QString aComment;
-  aComment.sprintf("myComment=ANIMATION;myType=%d;myTimeMinVal=%g;myTimeMaxVal=%g",
-                   VISU::TANIMATION,myTimeMinVal,myTimeMaxVal);
+  aComment.sprintf("myComment=ANIMATION;myType=%d;myTimeMinVal=%g;myTimeMaxVal=%g;myMode=%d",
+                   VISU::TANIMATION,myTimeMinVal,myTimeMaxVal,myAnimationMode);
 
   string anEntry = VISU::CreateAttributes(myStudy,aSComponentEntry.c_str(),"","",
                                           GenerateName(),"",aComment,true);
@@ -1117,8 +1496,8 @@ void VISU_TimeAnimation::saveAnimation()
   std::string aSComponentEntry = aSComponent->GetID();
 
   QString aComment;
-  aComment.sprintf("myComment=ANIMATION;myType=%d;myTimeMinVal=%g;myTimeMaxVal=%g",
-                   VISU::TANIMATION,myTimeMinVal,myTimeMaxVal);
+  aComment.sprintf("myComment=ANIMATION;myType=%d;myTimeMinVal=%g;myTimeMaxVal=%g;myMode=%d",
+                   VISU::TANIMATION,myTimeMinVal,myTimeMaxVal,myAnimationMode);
 
   _PTR(GenericAttribute) anAttr;
   anAttr = aStudyBuilder->FindOrCreateAttribute(aAnimSObject, "AttributeString");
@@ -1186,6 +1565,7 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField)
 
   myTimeMinVal = VISU::Storable::FindValue(aMap,"myTimeMinVal",&isExist).toDouble();
   myTimeMaxVal = VISU::Storable::FindValue(aMap,"myTimeMaxVal",&isExist).toDouble();
+  myAnimationMode = VISU::Storable::FindValue(aMap,"myMode",&isExist).toInt();
 
   _PTR(ChildIterator) anIter = myStudy->NewChildIterator(aAnimSObject);
   for (anIter->Init(); anIter->More(); anIter->Next()) {
@@ -1312,6 +1692,14 @@ bool VISU_TimeAnimation_i::addField (SALOMEDS::SObject_ptr theField)
   return myAnim->addField(theField);
 }
 
+void VISU_TimeAnimation_i::clearFields ()
+{
+  for (int i = 0; i < myAnim->getNbFields(); i++) {
+    myAnim->clearData(myAnim->getFieldData(i));
+  }
+  myAnim->clearFieldData();
+}
+
 CORBA::Boolean VISU_TimeAnimation_i::generateFrames()
 {
   //return ProcessEvent(new TMemFunEvent<VISU_TimeAnimation,bool>
@@ -1516,3 +1904,13 @@ void VISU_TimeAnimation_i::saveAnimation()
 {
   myAnim->saveAnimation();
 }
+
+void VISU_TimeAnimation_i::setAnimationMode(VISU::Animation::AnimationMode theMode)
+{
+  myAnim->setAnimationMode(theMode);
+}
+
+VISU::Animation::AnimationMode VISU_TimeAnimation_i::getAnimationMode()
+{
+  return VISU::Animation::AnimationMode(myAnim->getAnimationMode());
+}
index e45548432ed7dd63a4a9b379ca2f051a78e59d10..4d79215e31f94a3d2415ff31b3847e4bb02a13f1 100644 (file)
@@ -62,6 +62,7 @@ class VISU_TimeAnimation: public QObject, public QThread
   CORBA::Boolean _generateFrames();
   void _visibilityOff(int num_field, int num_frame);
   void _clearView();
+  void _clearData(FieldData& theData);
   void _stopAnimation();
   void _startAnimation();
   void _nextFrame();
@@ -73,6 +74,10 @@ class VISU_TimeAnimation: public QObject, public QThread
   void _emitFrameChanged(long theNewFrame, double theTime);
   void _emitStopped();
 
+  void parallelAnimation( bool& theIsDumping, QValueList<int>& theIndexList );
+  void consecutiveAnimation( bool& theIsDumping, QValueList<int>& theIndexList );
+  void saveImages( int theFieldId, double& theOneVal, int& theNbFiles, QValueList<int>& theIndexList );
+
  public:
   //static VISU::Result_i* createPresent (SALOMEDS::SObject_var theField);
   //static VISU::Storable::TRestoringMap getMapOfValue (SALOMEDS::SObject_var theSObject);
@@ -114,6 +119,9 @@ class VISU_TimeAnimation: public QObject, public QThread
   CORBA::Boolean isRunning() { return myIsActive; }
   CORBA::Long getCurrentFrame() { return myFrame; }
 
+  long getAbsoluteFrameNumber(std::pair<int,long> theFieldTimeStamp);
+  std::pair<int,long> getRelativeFrameNumber(long theFrame);
+
   VISU::ColoredPrs3d_ptr getPresentation(CORBA::Long theField, CORBA::Long theFrame);
 
   void setPresentationType(CORBA::Long theFieldNum, VISU::VISUType theType)
@@ -155,6 +163,9 @@ class VISU_TimeAnimation: public QObject, public QThread
   void saveAnimation();
   bool isSavedInStudy() const { return !myAnimEntry.isEmpty(); }
 
+  void setAnimationMode(int theMode) { myAnimationMode = theMode; }
+  int  getAnimationMode() { return myAnimationMode; }
+
  public slots:
   void setProportionalSlot(bool theProp) { myProportional = theProp; }
   void setCyclingSlot(bool theCycle) { myCycling = theCycle; }
@@ -177,12 +188,14 @@ class VISU_TimeAnimation: public QObject, public QThread
   QValueList<FieldData> myFieldsLst;
   bool myIsActive;
   long myFrame;
+  std::vector<long> myFieldsAbsFrames;
   int mySpeed;
   bool myProportional;
   bool myCycling;
   bool myCleaningMemoryAtEachFrame;
   _PTR(Study) myStudy;
 
+  int myAnimationMode;
   double myTimeMinVal, myTimeMaxVal; //!< Range of time stams, set by user
   double myTimeMin   , myTimeMax   ; //!< Range of time stams, available for animation
   QString myDumpPath;
@@ -210,6 +223,7 @@ public:
   //virtual VISU::VISUType GetType() { return VISU::TNONE; }
 
   virtual bool addField(SALOMEDS::SObject_ptr theField);
+  virtual void clearFields();
 
   virtual CORBA::Boolean generateFrames();
   virtual void generatePresentations(CORBA::Long theFieldNum);
@@ -262,6 +276,9 @@ public:
   virtual void restoreFromStudy(SALOMEDS::SObject_ptr theField);
   virtual CORBA::Boolean isSavedInStudy();
   virtual void saveAnimation();
+
+  virtual void setAnimationMode(VISU::Animation::AnimationMode theMode);
+  virtual VISU::Animation::AnimationMode getAnimationMode();
 };
 
 #endif  //VISU_TIMEANIMATION_H