]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To apply right scalar bar title for ScalarMapOnDeformedShape presentation
authorapo <apo@opencascade.com>
Thu, 17 May 2007 13:59:13 +0000 (13:59 +0000)
committerapo <apo@opencascade.com>
Thu, 17 May 2007 13:59:13 +0000 (13:59 +0000)
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 a5581e2cdbfdec63bdee868cc61d6090fa81de13..a3e8e67c45de82c1e9f72804c9ffa63339db7b3a 100644 (file)
@@ -314,16 +314,20 @@ VISU::ColoredPrs3d_i
 
 
 //----------------------------------------------------------------------------
-const VISU::PValForTime&
+VISU::PValForTime
 VISU::ColoredPrs3d_i
-::GetValForTime() const 
+::GetScalarValForTime() const 
 { 
   VISU::TValField& aValField = GetField()->myValField;
-  PValForTime& aValForTime = aValField[myTimeStampNumber];
+  PValForTime aValForTime;
+  VISU::TValField::iterator anIter = aValField.find(myTimeStampNumber);
+  if(anIter != aValField.end())
+    aValForTime = anIter->second;
   return aValForTime;
 }
 
 
+//----------------------------------------------------------------------------
 VISU::ColoredPrs3d::TimeStampsRange* 
 VISU::ColoredPrs3d_i
 ::GetTimeStampsRange()
@@ -707,14 +711,16 @@ void
 VISU::ColoredPrs3d_i
 ::SetTitle(const char* theTitle) 
 {
-  std::strstream aStream;
-  const VISU::PValForTime& aValForTime = GetValForTime();
-  aStream<<theTitle<<" "<<VISU_Convertor::GenerateName(aValForTime->myTime)<<std::ends;
-  std::string aScalarBarTitle = aStream.str();
-  if(myTitle != theTitle || myScalarBarTitle != aScalarBarTitle){
-    myScalarBarTitle = aScalarBarTitle;
-    myTitle = theTitle;
-    myParamsTime.Modified();
+  if(VISU::PValForTime aValForTime = GetScalarValForTime()){
+    std::strstream aStream;
+    const VISU::TTime& aTime = aValForTime->myTime;
+    aStream<<theTitle<<" "<<VISU_Convertor::GenerateName(aTime)<<std::ends;
+    std::string aScalarBarTitle = aStream.str();
+    if(myTitle != theTitle || myScalarBarTitle != aScalarBarTitle){
+      myScalarBarTitle = aScalarBarTitle;
+      myTitle = theTitle;
+      myParamsTime.Modified();
+    }
   }
 }
 
index f9539a326bb5c1a374f85fc3f32b70f7d02ce984..4120deb0e72d3c8d6371fd8aec2d425783355834 100644 (file)
@@ -103,8 +103,8 @@ namespace VISU
     GetTimeStampIndexByNumber( CORBA::Long theNumber );
 
     virtual 
-    const VISU::PValForTime&
-    GetValForTime() const;
+    VISU::PValForTime
+    GetScalarValForTime() const;
 
     virtual
     VISU::ColoredPrs3d::TimeStampsRange*
@@ -425,6 +425,7 @@ namespace VISU
     Storable* 
     Build(EBuildMode theBuildMode);
 
+    virtual
     void
     SetField(VISU::PField theField);
 
index 3b34e977b1a4b97106b33c8cb3618e48cb5ce5a8..fbc0e6f992c263b87f0866d9d2b238f948286f6f 100644 (file)
@@ -129,7 +129,7 @@ VISU::ScalarMapOnDeformedShape_i
   ColoredPrs3d_i(thePublishInStudyMode),
   ScalarMap_i(thePublishInStudyMode),
   myScalarMapOnDeformedShapePL(NULL),
-  myScalarIteration(1)
+  myScalarTimeStampNumber(1)
 {}
 
 
@@ -143,15 +143,16 @@ VISU::ScalarMapOnDeformedShape_i
 {
   myIsColored = true;
   myColor.R = myColor.G = myColor.B = 0.5;
-  VISU::Storable* aRes = TSuperClass::Create(theMeshName,
-                                            theEntity,
-                                            theFieldName,
-                                            theTimeStampNumber);
+
   SetScalarField(theMeshName.c_str(),
                 theFieldName.c_str(),
                 theTimeStampNumber,
                 theEntity);
-  return aRes;
+
+  return TSuperClass::Create(theMeshName,
+                            theEntity,
+                            theFieldName,
+                            theTimeStampNumber);
 }
 
 
@@ -161,9 +162,6 @@ VISU::ScalarMapOnDeformedShape_i
 ::Restore(SALOMEDS::Study_ptr theStudy,
          const Storable::TRestoringMap& theMap)
 {
-  if(!TSuperClass::Restore(theStudy, theMap))
-    return NULL;
-  
   QString aMeshName = VISU::Storable::FindValue(theMap,"myScalarMeshName");
   VISU::Entity anEntity = VISU::Entity(VISU::Storable::FindValue(theMap,"myScalarFieldName").toInt());
 
@@ -175,6 +173,9 @@ VISU::ScalarMapOnDeformedShape_i
                  aTimeStampNumber,
                  anEntity);
   
+  if(!TSuperClass::Restore(theStudy, theMap))
+    return NULL;
+  
   SetScale(VISU::Storable::FindValue(theMap,"myFactor").toDouble());
   myIsColored = VISU::Storable::FindValue(theMap,"myIsColored").toInt();
   myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
@@ -194,7 +195,7 @@ VISU::ScalarMapOnDeformedShape_i
   
   Storable::DataToStream( theStr, "myScalarFieldName", myScalarFieldName.c_str());
   Storable::DataToStream( theStr, "myScalarMeshName",  myScalarMeshName.c_str());
-  Storable::DataToStream( theStr, "myScalarIteration", int(myScalarIteration));
+  Storable::DataToStream( theStr, "myScalarIteration", int(myScalarTimeStampNumber));
   Storable::DataToStream( theStr, "myScalarEntity",    int(myScalarEntity));
 
   Storable::DataToStream( theStr, "myFactor", GetScale() );
@@ -350,6 +351,18 @@ VISU::ScalarMapOnDeformedShape_i
 }
 
 
+//---------------------------------------------------------------
+void
+VISU::ScalarMapOnDeformedShape_i
+::SetField(VISU::PField theField)
+{
+  TSuperClass::SetField(theField);
+  
+  if(!myScalarField)
+    myScalarField = theField;
+}
+
+
 //---------------------------------------------------------------
 void
 VISU::ScalarMapOnDeformedShape_i
@@ -370,14 +383,14 @@ VISU::ScalarMapOnDeformedShape_i
     anIsModified |= myScalarFieldName != theFieldName;
 
   if(!anIsModified)
-    anIsModified |= myScalarIteration != theTimeStampNumber;
+    anIsModified |= myScalarTimeStampNumber != theTimeStampNumber;
   
   if(!anIsModified)
     return;
 
   VISU::TEntity aEntity = VISU::TEntity(theEntity);
   VISU::Result_i::TInput* anInput = GetCResult()->GetInput();
-  SetField(anInput->GetField(theMeshName, aEntity, theFieldName));
+  myScalarField = anInput->GetField(theMeshName, aEntity, theFieldName);
 
   VISU::PUnstructuredGridIDMapper anIDMapper = 
     anInput->GetTimeStampOnMesh(theMeshName,
@@ -392,7 +405,10 @@ VISU::ScalarMapOnDeformedShape_i
   myScalarMeshName = theMeshName;
   myScalarEntity = theEntity;
   myScalarFieldName = theFieldName;
-  myScalarIteration = theTimeStampNumber;
+  myScalarTimeStampNumber = theTimeStampNumber;
+
+  SetTitle(theFieldName);
+
   myParamsTime.Modified();
 }
 
@@ -429,7 +445,21 @@ CORBA::Long
 VISU::ScalarMapOnDeformedShape_i
 ::GetScalarLIteration()
 {
-  return myScalarIteration;
+  return myScalarTimeStampNumber;
+}
+
+
+//----------------------------------------------------------------------------
+VISU::PValForTime
+VISU::ScalarMapOnDeformedShape_i
+::GetScalarValForTime() const 
+{ 
+  VISU::TValField& aValField = myScalarField->myValField;
+  PValForTime aValForTime;
+  VISU::TValField::iterator anIter = aValField.find(myScalarTimeStampNumber);
+  if(anIter != aValField.end())
+    aValForTime = anIter->second;
+  return aValForTime;
 }
 
 
index b5a8a056b9db7a3b3a75873c0bda9adb12bce836..3c265777916d71101265b3353723f32c8a4af361 100644 (file)
@@ -94,6 +94,11 @@ namespace VISU
     }
    
   protected:
+    //! Redefines VISU_ColoredPrs3d_i::SetField
+    virtual
+    void
+    SetField(VISU::PField theField);
+
     //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
     virtual
     void
@@ -104,14 +109,6 @@ namespace VISU
     bool 
     CheckIsPossible();
 
-    VISU_ScalarMapOnDeformedShapePL *myScalarMapOnDeformedShapePL;
-    SALOMEDS::Color myColor;
-    bool myIsColored;
-    std::string myScalarMeshName;
-    std::string myScalarFieldName;
-    VISU::Entity myScalarEntity;
-    CORBA::Long myScalarIteration;
-
   public:
     //! Redefines VISU_ColoredPrs3d_i::IsPossible
     static
@@ -186,6 +183,22 @@ namespace VISU
     virtual
     CORBA::Long
     GetScalarLIteration();
+
+    virtual 
+    VISU::PValForTime
+    GetScalarValForTime() const;
+
+  private:
+    VISU_ScalarMapOnDeformedShapePL *myScalarMapOnDeformedShapePL;
+
+    bool myIsColored;
+    SALOMEDS::Color myColor;
+
+    PField myScalarField;
+    std::string myScalarMeshName;
+    std::string myScalarFieldName;
+    VISU::Entity myScalarEntity;
+    CORBA::Long myScalarTimeStampNumber;
   };
 }
 #endif