From 8fcec890861024a2321e039dfd5fd6e46bf8082b Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 29 Aug 2007 10:10:27 +0000 Subject: [PATCH] Fix for Bug NPAL16763 - EDF 552 VISU : - Animation : Title modification only taken into account for the first time step. --- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 58 +++++++++++-------- src/VISU_I/VISU_ColoredPrs3d_i.cc | 8 ++- src/VISU_I/VISU_ColoredPrs3d_i.hh | 13 ++--- src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc | 43 ++++++++++---- src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh | 15 ++++- 5 files changed, 91 insertions(+), 46 deletions(-) diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 5bbf1f84..dad85109 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -785,6 +785,25 @@ void SetupDlg::onTypeChanged (int theIndex) //------------------------------------------------------------------------ namespace { + template + void + InitDiloglgFromPrsObject(TDialog* theDialog, + FieldData& theData) + { + theDialog->initFromPrsObject(dynamic_cast(theData.myPrs[0])); + } + + + template<> + void + InitDiloglgFromPrsObject + (VisuGUI_ScalarMapOnDeformedShapeDlg* theDialog, + FieldData& theData) + { + theDialog->initFromPrsObject(dynamic_cast(theData.myPrs[0]), true); + } + + template void EditPrs(VisuGUI* theModule, @@ -792,14 +811,25 @@ namespace VISU_TimeAnimation* theAnimator) { TDialog* aDlg = new TDialog(theModule); - aDlg->initFromPrsObject(dynamic_cast(theData.myPrs[0])); + InitDiloglgFromPrsObject(aDlg, theData); if (aDlg->exec()) { - for (int i = 0; i < theData.myNbFrames; i++) - aDlg->storeToPrsObject(dynamic_cast(theData.myPrs[i])); + aDlg->storeToPrsObject(dynamic_cast(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(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(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(aData.myPrs[i]); - aIter = i+1; - if(i+1 > anbFrames) - aIter=anbFrames; - aDlg->storeToPrsObject(aCurrPrs_i,false,aIter); - } - } - delete aDlg; - } + EditPrs(myModule,aData,myAnimator); break; case TVECTORS_ITEM: //Vectors c.suspend(); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index acc98b04..47b4f711 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -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 diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 03f07d9c..6b493ac2 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -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& diff --git a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc index 2b9f782f..cdba1fcd 100644 --- a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc +++ b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc @@ -158,26 +158,46 @@ void VISU::ScalarMapOnDeformedShape_i ::SameAs(const Prs3d_i* theOrigin) { - if(MYDEBUG) cout << "VISU::ScalarMapOnDeformedShape_i::SameAs:"<<__LINE__<GetScalarIteration(); - string theScalarMeshName = this->GetScalarMeshName(); - string theScalarFieldName = this->GetScalarFieldName(); - if(MYDEBUG) cout << "SameAs:"<(theOrigin)){ + ScalarMapOnDeformedShape_i* anOrigin = const_cast(aPrs3d); - TSuperClass::SameAs(theOrigin); - if(const ScalarMapOnDeformedShape_i* aPrs3d = dynamic_cast(theOrigin)){ - ScalarMapOnDeformedShape_i* anOrigin = const_cast(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(theOrigin)){ + ScalarMapOnDeformedShape_i* anOrigin = const_cast(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; } diff --git a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh index 37865e4e..5fed7b27 100644 --- a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh +++ b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh @@ -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); -- 2.39.2