]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
In context of [Bug NPAL15278] EDF 347 : ScalarMaponDeformedShape
authorapo <apo@opencascade.com>
Wed, 2 May 2007 13:09:11 +0000 (13:09 +0000)
committerapo <apo@opencascade.com>
Wed, 2 May 2007 13:09:11 +0000 (13:09 +0000)
Automatic scalar bar title regeneration on modification of scalar field or its timestamp

src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc
src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh

index 898e38f38920357f8413d2a86c27706dd972d772..0b713f68462dfdc1d446be00b7f51e7bdd0c3726 100644 (file)
@@ -108,30 +108,21 @@ VISU::Storable* VISU::ScalarMapOnDeformedShape_i::Create(const char* theMeshName
   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);
-  SetScalarFieldName(theFieldName);
-  SetScalarIteration(theIteration);
-  SetScalarMeshName(theMeshName);
-  int anEntity = theEntity;
-  SetScalarEntity(VISU::TEntity(anEntity));
-  SetScalarField(myScalarMeshName.c_str(),myScalarFieldName.c_str(),myScalarIteration,myScalarEntity);
-  return aRes;
+  SetScalarField(theMeshName, theFieldName, theIteration, VISU::TEntity(theEntity));
+  return TSuperClass::Create(theMeshName, theEntity, theFieldName, theIteration);
 }
 
 VISU::Storable* VISU::ScalarMapOnDeformedShape_i::Restore(const Storable::TRestoringMap& theMap)
 {
   if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::Restore:"<<__LINE__<<endl;
+  SetScalarField(VISU::Storable::FindValue(theMap,"myScalarMeshName"),
+                VISU::Storable::FindValue(theMap,"myScalarFieldName"),
+                VISU::Storable::FindValue(theMap,"myScalarIteration").toInt(),
+                VISU::TEntity(VISU::Storable::FindValue(theMap,"myScalarEntity").toInt()));
+
   TSuperClass::Restore(theMap);
-  
-  SetScalarFieldName(VISU::Storable::FindValue(theMap,"myScalarFieldName"));
-  SetScalarMeshName(VISU::Storable::FindValue(theMap,"myScalarMeshName"));
-  SetScalarIteration(VISU::Storable::FindValue(theMap,"myScalarIteration").toInt());
-  SetScalarEntity(VISU::TEntity(VISU::Storable::FindValue(theMap,"myScalarEntity").toInt()));
-  SetScalarField(GetScalarMeshName().c_str(),
-                GetScalarFieldName().c_str(),
-                GetScalarIteration(),
-                GetScalarEntity());
-  
+
   SetScale(VISU::Storable::FindValue(theMap,"myFactor").toDouble());
   myIsColored = VISU::Storable::FindValue(theMap,"myIsColored").toInt();
   myColor.R = VISU::Storable::FindValue(theMap,"myColor.R").toDouble();
@@ -187,6 +178,19 @@ VISU::ScalarMapOnDeformedShape_i
   }
 }
 
+void VISU::ScalarMapOnDeformedShape_i::SetTitle(const char* theTitle) 
+{
+  std::strstream aStream;
+  const VISU::TValField& aValField = myScalarField->myValField;
+  const VISU::PValForTime aValForTime = aValField.find(myScalarIteration)->second;
+  aStream<<theTitle<<" "<<VISU_Convertor::GenerateName(aValForTime->myTime)<<std::ends;
+  std::string aScalarBarTitle = aStream.str();
+  if(myTitle != theTitle || myScalarBarTitle != aScalarBarTitle){
+    myScalarBarTitle = aScalarBarTitle;
+    myTitle = theTitle;
+  }
+}
+
 void VISU::ScalarMapOnDeformedShape_i::SetScale(CORBA::Double theScale) { 
   myScalarMapOnDeformedShapePL->SetScale(theScale);
 }
@@ -323,7 +327,10 @@ char* VISU::ScalarMapOnDeformedShape_i::GetScalarCMeshName(){
 }
 
 void VISU::ScalarMapOnDeformedShape_i::SetScalarFieldName(const char* theName){
-  myScalarFieldName = theName;
+  if(myScalarFieldName != theName){
+    myScalarFieldName = theName;
+    SetTitle(theName);
+  }
 }
 
 std::string VISU::ScalarMapOnDeformedShape_i::GetScalarFieldName(){
@@ -335,7 +342,10 @@ char* VISU::ScalarMapOnDeformedShape_i::GetScalarCFieldName(){
 }
 
 void VISU::ScalarMapOnDeformedShape_i::SetScalarIteration(const int theValue){
-  myScalarIteration = theValue;
+  if(myScalarIteration != theValue){
+    myScalarIteration = theValue;
+    SetTitle(GetScalarFieldName().c_str());
+  }
 }
 
 
index 01542563d6261ee3ee70ad71ccee00bed5eee615..37865e4e2ed2c6e0d289a915f1b4478b939fae6a 100644 (file)
@@ -61,6 +61,8 @@ namespace VISU{
     
     typedef VISU::ScalarMapOnDeformedShape TInterface;
     
+    virtual void SetTitle(const char* theTitle);
+
     virtual void SetScale(CORBA::Double theScale);
     virtual CORBA::Double GetScale();