From dc73b29659c9d286131248c63118833e98965914 Mon Sep 17 00:00:00 2001 From: enk Date: Sun, 26 Feb 2006 15:10:14 +0000 Subject: [PATCH] Fix for Bug IPAL11503: CRASH after trying to "Show..." animation, based on "Scalar map on Deformad shape". --- .../VisuGUI_ScalarMapOnDeformedShapeDlg.cxx | 42 ++++++++++++------- .../VisuGUI_ScalarMapOnDeformedShapeDlg.h | 4 +- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 8 ++-- src/VISU_I/VISU_ColoredPrs3d_i.cc | 2 +- src/VISU_I/VISU_ColoredPrs3d_i.hh | 2 +- src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc | 35 ++++++++++++---- src/VISU_I/VISU_ScalarMapOnDeformedShape_i.hh | 4 ++ 7 files changed, 66 insertions(+), 31 deletions(-) diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx index 0d58049d..c8212c5b 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx @@ -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__<GetScalarIteration()="<GetScalarIteration()<GetScale()="<GetScale()<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__<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(); diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h index bf588c9e..6bc817c6 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h @@ -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; diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index acec9415..fe72f1dd 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -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(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; diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 8a691fd4..5501a17a 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -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(); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index e03d772e..9e277a47 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -166,7 +166,7 @@ namespace VISU void SameAsParams(const ColoredPrs3d_i* theOrigin); - const VISU::PField& + virtual const VISU::PField& GetField() const; const std::string& diff --git a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc index 75430d90..d462ab8f 100644 --- a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc +++ b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc @@ -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__<GetScalarIteration(); + string theScalarMeshName = this->GetScalarMeshName(); + string theScalarFieldName = this->GetScalarFieldName(); + if(MYDEBUG) cout << "SameAs:"<(theOrigin)){ ScalarMapOnDeformedShape_i* anOrigin = const_cast(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__<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__<(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__<