]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Modifications, which are concern to bug PAL11537:
authormkr <mkr@opencascade.com>
Wed, 25 Oct 2006 07:56:29 +0000 (07:56 +0000)
committermkr <mkr@opencascade.com>
Wed, 25 Oct 2006 07:56:29 +0000 (07:56 +0000)
1. Animation::addField(...) method returns now a boolean value.
2. All checks for compatibility of several animated fields
(according to time stamps number) were moved from
VisuGUI::OnTimeAnimation() slot to addField(...) method
of implementation.

idl/VISU_Gen.idl
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISUGUI/VisuGUI_TimeAnimation.h
src/VISU_I/VISU_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.h

index a0396431e3a0837fd1c16eceeb13cfcf315184d9..2c18149d19e2f49cdacc1c563fb431d501027904 100644 (file)
@@ -1156,7 +1156,7 @@ module VISU {
     /*! Defines the field which will be used as a base for generation of the animation.
      * \param theObject The %SObject corresponding to the field.
      */
-    void addField(in SALOMEDS::SObject theObject);
+    boolean addField(in SALOMEDS::SObject theObject);
 
     /*! Generates presentations on the basis of the field.
      * \param theFieldNum The number of the field, which will be used
index bc56f44402e1552a33fd72810db36d6e8f329f0b..13fc8200829561bb76949f2753ae0c5e0c6931b1 100644 (file)
@@ -52,6 +52,9 @@ msgstr "The object can't be built"
 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!"
+
 # Preferences for VISU module (VisuGUI.cxx)
 
 msgid "VISU_SCALAR_BAR"
index a0b3895a6acaf7d540d53f0d9a233753b2b9742b..7d94a704685840bba08532d1f52895db3d0c7a4d 100644 (file)
@@ -1655,27 +1655,19 @@ OnTimeAnimation()
   SALOME_ListIO aListIO;
   aSelectionMgr->selectedObjects(aListIO);
 
-  bool isDefined = false;
-  long aNbTimes = 0;
   SALOME_ListIteratorOfListIO It (aListIO);
   for (; It.More(); It.Next()) {
     _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
-    if (!aSObject) continue;
-    if (getValue(aSObject, "myComment") == QString("FIELD")) {
-      long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
-      if (aNumber > 1) {
-        if (!isDefined) {
-          aNbTimes = aNumber;
-          aAnimationDlg->addField(aSObject);
-          isDefined = true;
-        } else if (aNbTimes == aNumber) {
-          aAnimationDlg->addField(aSObject);
-        }
-      }
+    if ( !aAnimationDlg->addField(aSObject) ) {
+      SUIT_MessageBox::warn1(GetDesktop(this),
+                          tr("WRN_VISU"),
+                          tr("ERR_CANT_CREATE_ANIMATION"),
+                          tr("BUT_OK"));
+      delete aAnimationDlg;
+      return;
     }
   }
-  if (isDefined) aAnimationDlg->show();
-  else delete aAnimationDlg;
+  aAnimationDlg->show();
 }
 
 //************************************************************************
index 5345c71c05b5689b05d13b6fc3b2f35cdb74dbe4..dd50ee2daa01f5d605cedd5cb8dd238b6970b533 100644 (file)
@@ -1248,10 +1248,10 @@ void VisuGUI_TimeAnimationDlg::onTypeChange (int index)
 }
 
 //------------------------------------------------------------------------
-void VisuGUI_TimeAnimationDlg::addField (_PTR(SObject) theSObject)
+bool VisuGUI_TimeAnimationDlg::addField (_PTR(SObject) theSObject)
 {
   myPlayFrame->setEnabled(false);
-  myAnimator->addField(theSObject);
+  return myAnimator->addField(theSObject);
 }
 
 //------------------------------------------------------------------------
index 604cd24bc4e01c096528a04d86dadc0eafbc2862..6caff7f696f09320770c304be88014903aa74ef9 100644 (file)
@@ -146,7 +146,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog
     VisuGUI_TimeAnimationDlg(VisuGUI* theModule, _PTR(Study) theStudy);
     ~VisuGUI_TimeAnimationDlg();
 
-    void addField(_PTR(SObject) theField);
+    bool addField(_PTR(SObject) theField);
     void clearView();
 
     void restoreFromStudy(_PTR(SObject) theAnimation);
index a34e20521f3f4537ad5bbb369f6b6f4aed32fb67..fa85ef875ecf9fc5a04537f22361eb8b12abb5d0 100644 (file)
@@ -145,15 +145,26 @@ VISU_TimeAnimation::~VISU_TimeAnimation()
 
 
 //------------------------------------------------------------------------
-void VISU_TimeAnimation::addField (_PTR(SObject) theField)
+bool VISU_TimeAnimation::addField (_PTR(SObject) theField)
 {
+  if (!theField) return false;
+
   FieldData aNewData;
   aNewData.myField = theField;
   aNewData.myNbFrames = 0;
   aNewData.myPrsType = VISU::TSCALARMAP;
   aNewData.myOffset[0] = aNewData.myOffset[1] = aNewData.myOffset[2] = 0;
   VISU::Storable::TRestoringMap aMap = getMapOfValue(aNewData.myField);
+  if(VISU::Storable::FindValue(aMap,"myComment") != QString("FIELD"))
+    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;
+
   myFieldsLst.append(aNewData);
 
   //find Min/Max timestamps
@@ -165,14 +176,16 @@ void VISU_TimeAnimation::addField (_PTR(SObject) theField)
       myTimeMax = getTimeValue(anIter->Value());
     }
   }
+  
+  return true;
 }
 
 //------------------------------------------------------------------------
-void VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField)
+bool VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField)
 {
   SALOMEDS::SObject_var theFieldDup = SALOMEDS::SObject::_duplicate(theField);
   _PTR(SObject) aField = VISU::GetClientSObject(theFieldDup, myStudy);
-  addField(aField);
+  return addField(aField);
 }
 
 
@@ -1294,9 +1307,9 @@ VISU_TimeAnimation_i::~VISU_TimeAnimation_i()
   delete myAnim;
 }
 
-void VISU_TimeAnimation_i::addField (SALOMEDS::SObject_ptr theField)
+bool VISU_TimeAnimation_i::addField (SALOMEDS::SObject_ptr theField)
 {
-  myAnim->addField(theField);
+  return myAnim->addField(theField);
 }
 
 CORBA::Boolean VISU_TimeAnimation_i::generateFrames()
index 0c99f7e81b4646a9cecc10e7fb890a28352ce6e4..e45548432ed7dd63a4a9b379ca2f051a78e59d10 100644 (file)
@@ -88,8 +88,8 @@ class VISU_TimeAnimation: public QObject, public QThread
 
   virtual VISU::VISUType GetType() { return VISU::TNONE;};
 
-  void addField (_PTR(SObject) theField);
-  void addField (SALOMEDS::SObject_ptr theField);
+  bool addField (_PTR(SObject) theField);
+  bool addField (SALOMEDS::SObject_ptr theField);
   FieldData& getFieldData (int theNum) { return myFieldsLst[theNum]; }
 
   CORBA::Boolean generateFrames();
@@ -209,7 +209,7 @@ public:
   virtual VISU::VISUType GetType() { return VISU::TANIMATION; }
   //virtual VISU::VISUType GetType() { return VISU::TNONE; }
 
-  virtual void addField(SALOMEDS::SObject_ptr theField);
+  virtual bool addField(SALOMEDS::SObject_ptr theField);
 
   virtual CORBA::Boolean generateFrames();
   virtual void generatePresentations(CORBA::Long theFieldNum);