]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug NPAL16763 - EDF 552 VISU : T_13901 mergeto_BR_Dev_For_4_0_31Aug2007
authorapo <apo@opencascade.com>
Wed, 29 Aug 2007 10:10:27 +0000 (10:10 +0000)
committerapo <apo@opencascade.com>
Wed, 29 Aug 2007 10:10:27 +0000 (10:10 +0000)
  - Animation : Title modification only taken into account for the first time step.

src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc
src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh

index 5bbf1f847a723680368cce65a7b42763b3f52f6f..dad851092150a4d623168f8c3c2aad4cf50dfd55 100644 (file)
@@ -785,6 +785,25 @@ void SetupDlg::onTypeChanged (int theIndex)
 //------------------------------------------------------------------------
 namespace
 {
+  template<class TPrs3d, class TDialog>
+  void
+  InitDiloglgFromPrsObject(TDialog* theDialog,
+                          FieldData& theData)
+  {
+    theDialog->initFromPrsObject(dynamic_cast<TPrs3d*>(theData.myPrs[0]));
+  }
+
+
+  template<>
+  void
+  InitDiloglgFromPrsObject
+  <VISU::ScalarMapOnDeformedShape_i, VisuGUI_ScalarMapOnDeformedShapeDlg>(VisuGUI_ScalarMapOnDeformedShapeDlg* theDialog,
+                                                                         FieldData& theData)
+  {
+    theDialog->initFromPrsObject(dynamic_cast<VISU::ScalarMapOnDeformedShape_i*>(theData.myPrs[0]), true);
+  }
+
+
   template<class TPrs3d, class TDialog>
   void
   EditPrs(VisuGUI* theModule,
@@ -792,14 +811,25 @@ namespace
          VISU_TimeAnimation* theAnimator)
   {
     TDialog* aDlg = new TDialog(theModule);
-    aDlg->initFromPrsObject(dynamic_cast<TPrs3d*>(theData.myPrs[0]));
+    InitDiloglgFromPrsObject<TPrs3d, TDialog>(aDlg, theData);
     if (aDlg->exec()) {
-      for (int i = 0; i < theData.myNbFrames; i++)
-       aDlg->storeToPrsObject(dynamic_cast<TPrs3d*>(theData.myPrs[i]));
+      aDlg->storeToPrsObject(dynamic_cast<TPrs3d*>(theData.myPrs[0]));
+      for (int i = 1; i < theData.myNbFrames; i++)
+       theData.myPrs[i]->SameAsParams(theData.myPrs[0],
+                                      theData.myPrs[i]->GetMeshName(),
+                                      theData.myPrs[i]->GetFieldName(),
+                                      theData.myPrs[i]->GetEntity(), 
+                                      theData.myPrs[i]->GetIteration(),
+                                      true);
       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]));
+           theAnimator->getFieldData(i).myPrs[j]->SameAsParams(theData.myPrs[0],
+                                                               theData.myPrs[j]->GetMeshName(),
+                                                               theData.myPrs[j]->GetFieldName(),
+                                                               theData.myPrs[j]->GetEntity(), 
+                                                               theData.myPrs[j]->GetIteration(),
+                                                               true);
        }
       }
     }
@@ -860,25 +890,7 @@ void SetupDlg::onPreferencesDlg()
     break;
   case TSCALARMAPONDEFORMEDSHAPE_ITEM: //Scalar Map on Deformed Shape
     c.suspend();
-    {
-      typedef VisuGUI_ScalarMapOnDeformedShapeDlg DLG;
-      typedef VISU::ScalarMapOnDeformedShape_i TYPE;
-      DLG* aDlg = new DLG (myModule);
-      aDlg->initFromPrsObject(dynamic_cast<TYPE*>(aData.myPrs[0]),true);
-      if (aDlg->exec())
-        { 
-         int anbFrames=aDlg->getCurrentScalarNbIterations();
-         int aIter = 0;
-         for (int i = 0; i < aData.myNbFrames; i++){
-           TYPE* aCurrPrs_i = dynamic_cast<TYPE*>(aData.myPrs[i]);
-           aIter = i+1;
-           if(i+1 > anbFrames)
-             aIter=anbFrames;
-           aDlg->storeToPrsObject(aCurrPrs_i,false,aIter);
-         }
-       }
-      delete aDlg;
-    }
+    EditPrs<VISU::ScalarMapOnDeformedShape_i,VisuGUI_ScalarMapOnDeformedShapeDlg>(myModule,aData,myAnimator);
     break;
   case TVECTORS_ITEM: //Vectors
     c.suspend();
index acc98b043575b88d8ef7286babe520d0213d98e2..47b4f711ecce2cb9f594198d9ff7f2e36ff375e1 100644 (file)
@@ -144,8 +144,10 @@ VISU::ColoredPrs3d_i
 void
 VISU::ColoredPrs3d_i
 ::SameAsParams(const ColoredPrs3d_i* theOrigin, 
-              const std::string& theMeshName, const std::string& theFieldName,
-              VISU::Entity theEntity, int theIteration,
+              const std::string& theMeshName, 
+              const std::string& theFieldName,
+              VISU::Entity theEntity, 
+              int theIteration,
               bool theIsFixedRange)
 {
   myMeshName = theMeshName;
@@ -503,7 +505,7 @@ VISU::ColoredPrs3d_i
 
   myMeshName = theMeshName;
   myEntity = (VISU::TEntity)theEntity;
-  myFieldName =theFieldName;
+  myFieldName = theFieldName;
   myIteration = theIteration;
 
   Build(false); // to get corresponding input from result and initilize the pipeline
index 03f07d9cdfd63a719bcc06b4a28f81d36dadd4d2..6b493ac2ac8ce87b02a9ce2406487b1008afa4f7 100644 (file)
@@ -159,15 +159,14 @@ namespace VISU
     void
     SameAs(const Prs3d_i* theOrigin);
 
-    /*!
-     *  \brief Works like SameAs() method, but keep myIteration value unchanged.
-     *
-     *  Is used in VISU_TimeAnimation class implementation.
-     */
+    //! Works like SameAs() method, but allows to customize some key parameters
+    virtual
     void
     SameAsParams(const ColoredPrs3d_i* theOrigin, 
-                const std::string& theMeshName, const std::string& theFieldName,
-                VISU::Entity theEntity, int theIteration,
+                const std::string& theMeshName, 
+                const std::string& theFieldName,
+                VISU::Entity theEntity, 
+                int theIteration,
                 bool theIsFixedRange);
 
     virtual const VISU::PField&
index 2b9f782f9eadd8c735430b5ad5e52819f6cd4d63..cdba1fcd0558bff38900dced0351ff94772d8615 100644 (file)
@@ -158,26 +158,46 @@ void
 VISU::ScalarMapOnDeformedShape_i
 ::SameAs(const Prs3d_i* theOrigin)
 {
-  if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::SameAs:"<<__LINE__<<endl;
-  int theScalarIter = this->GetScalarIteration();
-  string theScalarMeshName = this->GetScalarMeshName();
-  string theScalarFieldName = this->GetScalarFieldName();
-  if(MYDEBUG) cout << "SameAs:"<<endl
-                  << "\t"<<theScalarIter<<":"<<theScalarMeshName.c_str()<<":"<<theScalarFieldName.c_str()<<endl;
+  if(const ScalarMapOnDeformedShape_i* aPrs3d = dynamic_cast<const ScalarMapOnDeformedShape_i*>(theOrigin)){   
+    ScalarMapOnDeformedShape_i* anOrigin = const_cast<ScalarMapOnDeformedShape_i*>(aPrs3d);
 
-  TSuperClass::SameAs(theOrigin);
 
-  if(const ScalarMapOnDeformedShape_i* aPrs3d = dynamic_cast<const ScalarMapOnDeformedShape_i*>(theOrigin)){
-    ScalarMapOnDeformedShape_i* anOrigin = const_cast<ScalarMapOnDeformedShape_i*>(aPrs3d);
+    TSuperClass::SameAs(theOrigin);
 
     this->SetScalarField(anOrigin->GetScalarMeshName().c_str(),
                         anOrigin->GetScalarFieldName().c_str(),
-                        theScalarIter,
+                        anOrigin->GetScalarIteration(),
                         anOrigin->GetScalarEntity());
+
+    // To restore the original title
+    this->SetTitle(anOrigin->GetTitle());
+  }
+}
+
+void
+VISU::ScalarMapOnDeformedShape_i
+::SameAsParams(const ColoredPrs3d_i* theOrigin, 
+              const std::string& theMeshName, 
+              const std::string& theFieldName,
+              VISU::Entity theEntity, 
+              int theIteration,
+              bool theIsFixedRange)
+{
+  if(const ScalarMapOnDeformedShape_i* aPrs3d = dynamic_cast<const ScalarMapOnDeformedShape_i*>(theOrigin)){   
+    ScalarMapOnDeformedShape_i* anOrigin = const_cast<ScalarMapOnDeformedShape_i*>(aPrs3d);
+
+    TSuperClass::SameAsParams(theOrigin, theMeshName, theFieldName, theEntity, theIteration, theIsFixedRange);
+    
+    this->SetScalarIteration(theIteration);
+
+    // To restore the original title
+    this->SetTitle(anOrigin->GetTitle());
+
     Update();
   }
 }
 
+
 void VISU::ScalarMapOnDeformedShape_i::SetTitle(const char* theTitle) 
 {
   std::strstream aStream;
@@ -348,14 +368,13 @@ char* VISU::ScalarMapOnDeformedShape_i::GetScalarCFieldName(){
   return &this->GetScalarFieldName()[0];
 }
 
-void VISU::ScalarMapOnDeformedShape_i::SetScalarIteration(const int theValue){
+void VISU::ScalarMapOnDeformedShape_i::SetScalarIteration(int theValue){
   if(myScalarIteration != theValue){
     myScalarIteration = theValue;
     SetTitle(GetScalarFieldName().c_str());
   }
 }
 
-
 int VISU::ScalarMapOnDeformedShape_i::GetScalarIteration(){
   return myScalarIteration;
 }
index 37865e4e2ed2c6e0d289a915f1b4478b939fae6a..5fed7b27cdf7f6e6fa3551a1060cfac4ae8bdb79 100644 (file)
@@ -97,6 +97,16 @@ namespace VISU{
     void
     SameAs(const Prs3d_i* theOrigin);
 
+    //! Reimplements the VISU::ColoredPrs3d_i::SameAsParams method
+    virtual
+    void
+    SameAsParams(const ColoredPrs3d_i* theOrigin, 
+                const std::string& theMeshName, 
+                const std::string& theFieldName,
+                VISU::Entity theEntity, 
+                int theIteration,
+                bool theIsFixedRange);
+
     virtual const VISU::PField&
     GetField() const;
 
@@ -160,12 +170,15 @@ namespace VISU{
     virtual void SetScalarFieldName(const char* theName);
     virtual std::string GetScalarFieldName();
     virtual char* GetScalarCFieldName();
-    virtual void SetScalarIteration(const int theValue);
+
+    virtual void SetScalarIteration(int theValue);
     virtual int GetScalarIteration();
     virtual CORBA::Long GetScalarLIteration();
+
     virtual void SetScalarMeshName(const char* theName);
     virtual std::string GetScalarMeshName();
     virtual char* GetScalarCMeshName();
+
     virtual void SetScalarEntity(const VISU::TEntity theValue);
     virtual VISU::TEntity GetScalarEntity();
     virtual void SetScalarEEntity(const VISU::Entity theValue);