]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug IPAL11503:
authorenk <enk@opencascade.com>
Sun, 26 Feb 2006 15:10:14 +0000 (15:10 +0000)
committerenk <enk@opencascade.com>
Sun, 26 Feb 2006 15:10:14 +0000 (15:10 +0000)
CRASH after trying to "Show..." animation, based on "Scalar map on Deformad shape".

src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx
src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h
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 0d58049db35cbd4231ec6094da410218f5acec14..c8212c5ba9804ce63004eefe9c99cdf2951857fc 100644 (file)
@@ -55,6 +55,7 @@ using namespace std;
 VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (SalomeApp_Module* theModule)
     : QDialog(VISU::GetDesktop(theModule), "VisuGUI_ScalarMapOnDeformedShapeDlg", false,
               WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
+      myIsAnimation(false),
       myVisuGUI(theModule)
 {
   myPrs = NULL;
@@ -148,16 +149,19 @@ VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (Salome
 
 void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject (VISU::ScalarMapOnDeformedShape_i* thePrs,bool isAnim)
 {
+  if(MYDEBUG) cout << "VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject:"<<__LINE__<<endl;
+  if(MYDEBUG) cout << "\tthePrs->GetScalarIteration()="<<thePrs->GetScalarIteration()<<endl;
+  if(MYDEBUG) cout << "\tthePrs->GetScale()="<<thePrs->GetScale()<<endl;
+  myIsAnimation = isAnim;
   myPrs = thePrs;
-
-  setFactor(thePrs->GetScale());
+  setFactor(myPrs->GetScale());
   myTimeStampsCombo->setDisabled(isAnim);
   
-  QString aFieldName(thePrs->GetScalarFieldName());
-  float aIterFloat = GetFloatValueOfTimeStamp(thePrs->GetMeshName().c_str(),
-                                             thePrs->GetScalarFieldName().c_str(),
-                                             thePrs->GetScalarIteration(),
-                                             thePrs->GetScalarEntity());
+  QString aFieldName(myPrs->GetScalarFieldName());
+  float aIterFloat = GetFloatValueOfTimeStamp(myPrs->GetMeshName().c_str(),
+                                             myPrs->GetScalarFieldName().c_str(),
+                                             myPrs->GetScalarIteration(),
+                                             myPrs->GetScalarEntity());
   QString aIteration(QString("%1").arg(aIterFloat));
   
   if (myMeshFieldsTimes.size() == 0)
@@ -240,7 +244,7 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject (VISU::ScalarMapOnDe
                  _PTR(AttributeName) aName (aNameAttr);
                  VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject);
                  QString aMeshName  = VISU::getValue(aChildSObj,"myMeshName");
-                 if(QString(thePrs->GetMeshName().c_str()) != aMeshName) continue;
+                 if(QString(myPrs->GetMeshName().c_str()) != aMeshName) continue;
                  myCurrMeshName = aMeshName;
                  QString aFieldName = VISU::getValue(aChildSObj,"myFieldName");
                  QString aTimeIter  = VISU::getValue(aChildSObj,"myTimeStampId");
@@ -278,16 +282,22 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject (VISU::ScalarMapOnDe
   myScalarPane->initFromPrsObject(myPrs);
 }
 
-int VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs, bool theUpdateScalar) {
-
+int VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs,bool theUpdateScalars, int theIter) {
+  if(MYDEBUG) cout << "VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject:"<<__LINE__<<endl;
   thePrs->SetScale(getFactor());
   
-  thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(),
-                        myPrs->GetScalarFieldName().c_str(),
-                        myPrs->GetScalarIteration(),
-                        myPrs->GetScalarEntity());
+  if(myIsAnimation)
+    thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(),
+                          getCurrentScalarFieldName().latin1(),
+                          theIter,
+                          myPrs->GetScalarEntity());
+  else
+    thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(),
+                          getCurrentScalarFieldName().latin1(),
+                          myTimeStampsCombo->currentItem()+1,
+                          myPrs->GetScalarEntity());
 
-  if (theUpdateScalar) SetScalarField();
+  if (theUpdateScalars) SetScalarField();
 
   thePrs->ShowColored(true);
 
@@ -341,7 +351,7 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::SetScalarField(int theIter,QString the
                        aFieldName.latin1(),
                        theIter,
                        anEntity);
-  
+
   myScalarPane->storeToPrsObject(myPrs);
   
   UpdateScalarField();
index bf588c9e429e2f62e9f3c7e40261a65ae30ffdb5..6bc817c6b4b128c3d9bdd33ae3f759dafd3fe386 100644 (file)
@@ -63,7 +63,7 @@ public:
     
 
     void initFromPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs,bool isAnim=false);
-    int storeToPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs,bool theUpdateScalar=true);
+    int storeToPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs,bool theUpdateScalars=true,int theIter=1);
 
     int getCurrentScalarFieldNamePos();
     QString getCurrentScalarFieldName();
@@ -92,6 +92,8 @@ private:
  
  TMF myMeshFieldsTimes;
  QString myCurrMeshName;
+ int myCurrScalarIter;
+ bool myIsAnimation;
  
  _PTR(SObject) mySelectionObj;
  VISU::ScalarMapOnDeformedShape_i* myPrs;
index acec9415765f2173c32e4daea62446412a8e0b47..fe72f1dd16a3656c3e67d6b480e75d94a1048f8d 100644 (file)
@@ -769,13 +769,13 @@ void SetupDlg::onPreferencesDlg()
       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)
-             aDlg->SetScalarField(anbFrames);
-           else
-             aDlg->SetScalarField(i+1);
-           aDlg->storeToPrsObject(aCurrPrs_i,false);
+             aIter=anbFrames;
+           aDlg->storeToPrsObject(aCurrPrs_i,false,aIter);
          }
        }
       delete aDlg;
index 8a691fd463f73a1af1366f1c0df165bfb158b957..5501a17ada3f85bd6b671ae9d0b84eaf7a8bc60f 100644 (file)
@@ -107,7 +107,7 @@ VISU::ColoredPrs3d_i
  
     myField = anOrigin->GetField();
     myMeshName = myField->myMeshName;
-    myEntity = myField->myEntity;
+    myEntity = VISU::TEntity(anOrigin->GetEntity());//myField->myEntity;
     myIteration = anOrigin->GetIteration();
     myFieldName = anOrigin->GetFieldName();
     
index e03d772eae5123da9cbe52c9c451904bbbe6b47f..9e277a47e4f46a209bac769872a16b7b8127c7bc 100644 (file)
@@ -166,7 +166,7 @@ namespace VISU
     void
     SameAsParams(const ColoredPrs3d_i* theOrigin);
 
-    const VISU::PField&
+    virtual const VISU::PField&
     GetField() const;
 
     const std::string& 
index 75430d9088eae6e4dabb2d549b29715d04e849d7..d462ab8f53324db50b3b2ad04f4ad91ebeafff4c 100644 (file)
@@ -102,6 +102,7 @@ ScalarMapOnDeformedShape_i(Result_i* theResult,
 VISU::Storable* VISU::ScalarMapOnDeformedShape_i::Create(const char* theMeshName, VISU::Entity theEntity, 
                                                         const char* theFieldName, int theIteration)
 {
+  if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::Create:"<<__LINE__<<endl;
   myIsColored = true;
   myColor.R = myColor.G = myColor.B = 0.5;
   VISU::Storable* aRes = TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration);
@@ -116,6 +117,7 @@ VISU::Storable* VISU::ScalarMapOnDeformedShape_i::Create(const char* theMeshName
 
 VISU::Storable* VISU::ScalarMapOnDeformedShape_i::Restore(const Storable::TRestoringMap& theMap)
 {
+  if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::Restore:"<<__LINE__<<endl;
   TSuperClass::Restore(theMap);
   
   SetScalarFieldName(VISU::Storable::FindValue(theMap,"myScalarFieldName"));
@@ -138,6 +140,7 @@ VISU::Storable* VISU::ScalarMapOnDeformedShape_i::Restore(const Storable::TResto
 
 void VISU::ScalarMapOnDeformedShape_i::ToStream(std::ostringstream& theStr)
 {
+  if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::ToStream:"<<__LINE__<<endl;
   TSuperClass::ToStream(theStr);
   
   Storable::DataToStream( theStr, "myScalarFieldName", myScalarFieldName.c_str());
@@ -161,15 +164,18 @@ void
 VISU::ScalarMapOnDeformedShape_i
 ::SameAs(const Prs3d_i* theOrigin)
 {
-  int theScalarIter = GetScalarIteration();
+  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;
 
   TSuperClass::SameAs(theOrigin);
 
   if(const ScalarMapOnDeformedShape_i* aPrs3d = dynamic_cast<const ScalarMapOnDeformedShape_i*>(theOrigin)){
     ScalarMapOnDeformedShape_i* anOrigin = const_cast<ScalarMapOnDeformedShape_i*>(aPrs3d);
 
-    // increment the scalar iteration for using in VISU_TimeAnimation class implementation.
-    int anOriginScalarIter = anOrigin->GetScalarIteration();
     this->SetScalarField(anOrigin->GetScalarMeshName().c_str(),
                         anOrigin->GetScalarFieldName().c_str(),
                         theScalarIter,
@@ -207,6 +213,7 @@ CORBA::Double VISU::ScalarMapOnDeformedShape_i::GetSourceRangeMax(){
 
 void VISU::ScalarMapOnDeformedShape_i::DoHook()
 {
+  if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::DoHook:"<<__LINE__<<endl;
   if(!myPipeLine)
     myPipeLine = VISU_ScalarMapOnDeformedShapePL::New();
   
@@ -218,6 +225,7 @@ void VISU::ScalarMapOnDeformedShape_i::DoHook()
 
 VISU_Actor* VISU::ScalarMapOnDeformedShape_i::CreateActor(const Handle(SALOME_InteractiveObject)& theIO) 
 {
+  if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::CreateActor:"<<__LINE__<<endl;
   VISU_Actor* anActor = TSuperClass::CreateActor(theIO);
   anActor->SetRepresentation(2);
   anActor->GetProperty()->SetColor(myColor.R,myColor.G,myColor.B);
@@ -227,6 +235,7 @@ VISU_Actor* VISU::ScalarMapOnDeformedShape_i::CreateActor(const Handle(SALOME_In
 
 
 void VISU::ScalarMapOnDeformedShape_i::UpdateActor(VISU_Actor* theActor) {
+  if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::UpdateActor:"<<__LINE__<<endl;
   if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor)){
     if(IsColored()){
       anActor->SetBarVisibility(true);
@@ -245,12 +254,15 @@ void VISU::ScalarMapOnDeformedShape_i::SetScalarField(const char* theMeshName,
                                                      const int   theIteration,
                                                      const VISU::TEntity  theEntity)
 {
+  if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::SetScalarField:"<<__LINE__<<endl;
+  if(MYDEBUG) cout << "\ttheFieldName="<<theFieldName<<endl;
+  if(MYDEBUG) cout << "\ttheIteration="<<theIteration<<endl;
+  myScalarField = myResult->GetInput()->GetField(theMeshName,theEntity,theFieldName);
+  TVTKOutput* aOut = myResult->GetInput()->GetTimeStampOnMesh(theMeshName,
+                                                             theEntity,
+                                                             theFieldName,
+                                                             theIteration)->GetVTKOutput();
   if (myScalarMapOnDeformedShapePL){
-    myField = myResult->GetInput()->GetField(theMeshName,theEntity,theFieldName);
-    TVTKOutput* aOut = myResult->GetInput()->GetTimeStampOnMesh(theMeshName,
-                                                               theEntity,
-                                                               theFieldName,
-                                                               theIteration)->GetVTKOutput();
     myScalarMapOnDeformedShapePL->SetScalars(aOut);
   }
   this->SetScalarMeshName(theMeshName);
@@ -287,3 +299,10 @@ void VISU::ScalarMapOnDeformedShape_i::SetScalarEntity(const VISU::TEntity theVa
 VISU::TEntity VISU::ScalarMapOnDeformedShape_i::GetScalarEntity(){
   return myScalarEntity;
 }
+
+const VISU::PField&
+VISU::ScalarMapOnDeformedShape_i
+::GetField() const 
+{ 
+  return myScalarField;
+}
index b7433720fc83292ecdd45f07bebc6c3a9e7b6270..0a2ee955b9625b0a935740bc48735cce04a7a3f0 100644 (file)
@@ -78,6 +78,9 @@ namespace VISU{
     void
     SameAs(const Prs3d_i* theOrigin);
 
+    virtual const VISU::PField&
+    GetField() const;
+
     VISU_ScalarMapOnDeformedShapePL* GetScalarMapOnDeformedShapePL(){ return myScalarMapOnDeformedShapePL;}
    
   protected:
@@ -93,6 +96,7 @@ namespace VISU{
     std::string myScalarFieldName;
     VISU::TEntity myScalarEntity;
     int myScalarIteration;
+    PField myScalarField;
 
   public:
     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,