From 4f6c3c4562b2cedff848a7886c6e42ff556425eb Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 28 Feb 2006 08:15:34 +0000 Subject: [PATCH] Fix for bug 11597: SIGSEGV during animation edition. --- .../VisuGUI_ScalarMapOnDeformedShapeDlg.cxx | 146 ++++++++-------- src/VISUGUI/VisuGUI_StreamLinesDlg.cxx | 163 +++++++++++------- 2 files changed, 179 insertions(+), 130 deletions(-) diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx index c8212c5b..54f79c9c 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx @@ -26,19 +26,23 @@ // Module : VISU #include "VisuGUI_ScalarMapOnDeformedShapeDlg.h" + #include "VisuGUI_Tools.h" + #include "VISU_Result_i.hh" #include "VISU_ScalarMapOnDeformedShape_i.hh" + +#include "VISU_ScalarMapPL.hxx" #include "VISU_ScalarMapOnDeformedShapePL.hxx" + +#include "VISU_Convertor.hxx" + #include "SalomeApp_Module.h" #include "LightApp_SelectionMgr.h" #include "SUIT_Desktop.h" -#include "VISU_ScalarMapPL.hxx" #include "SALOME_ListIO.hxx" -#include "VISU_Convertor.hxx" - #include "SALOMEDSClient_AttributeComment.hxx" #include "SALOMEDSClient_AttributeName.hxx" @@ -95,14 +99,14 @@ VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (Salome TopGroupLayout->addWidget(FieldLabel, 1, 0); TopGroupLayout->addWidget(myFieldsCombo,1,1); - + // TimeStamps combo box QLabel* TimeStampLabel = new QLabel (tr("TIMESTAMP_ITEM"), TopGroup, "TimeStampLabel"); myTimeStampsCombo = new QComboBox (TopGroup,"TimeStamp"); TopGroupLayout->addWidget(TimeStampLabel, 2, 0); TopGroupLayout->addWidget(myTimeStampsCombo,2,1); - + // aTabBox->addTab(aBox, tr("SCALAR_MAP_ON_DEFORMED_SHAPE_TAB")); @@ -144,26 +148,24 @@ VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (Salome connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(myFieldsCombo, SIGNAL(activated(int)), this, SLOT(onFieldChanged(int))); connect(myTimeStampsCombo, SIGNAL(activated(int)), this, SLOT(onTimeStampChanged(int))); - } -void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject (VISU::ScalarMapOnDeformedShape_i* thePrs,bool isAnim) +void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject + (VISU::ScalarMapOnDeformedShape_i* thePrs, bool isAnim) { - if(MYDEBUG) cout << "VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject:"<<__LINE__<GetScalarIteration()="<GetScalarIteration()<GetScale()="<GetScale()<GetScale()); myTimeStampsCombo->setDisabled(isAnim); - + 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) { // find all fields and time stamps on it @@ -175,15 +177,17 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject (VISU::ScalarMapOnDe Handle(SALOME_InteractiveObject) aIO = selected.First(); if (aIO->hasEntry()) { _PTR(SObject) aSObject = aActiveStudy->FindObjectID(aIO->getEntry()); + _PTR(GenericAttribute) anTmpAttr; - if(aSObject->FindAttribute(anTmpAttr, "AttributeComment")){ + if (aSObject->FindAttribute(anTmpAttr, "AttributeComment")) { _PTR(AttributeComment) aTmpComment (anTmpAttr); string aTmpComm = aTmpComment->Value(); QString aTmpstrIn (aTmpComm.c_str()); VISU::Storable::TRestoringMap aTmpaMap; VISU::Storable::StrToMap(aTmpstrIn,aTmpaMap); bool aTmpisExist; - VISU::VISUType aTmpType = (VISU::VISUType)VISU::Storable::FindValue(aTmpaMap,"myType",&aTmpisExist).toInt(); + VISU::VISUType aTmpType = + (VISU::VISUType)VISU::Storable::FindValue(aTmpaMap,"myType",&aTmpisExist).toInt(); switch(aTmpType){ case VISU::TTIMESTAMP: { @@ -214,65 +218,68 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject (VISU::ScalarMapOnDe } } } + aSObject = aSObject->GetFather(); aSObject = aSObject->GetFather(); + mySelectionObj = aSObject; CORBA::Object_var anObject = VISU::ClientSObjectToObject(mySelectionObj); - VISU::Result_var aResult; if (CORBA::is_nil(anObject)) { mySelectionObj = mySelectionObj->GetFather(); } - _PTR(ChildIterator) aIter = aActiveStudy->NewChildIterator(mySelectionObj); - - for (aIter->InitEx(true); aIter->More(); aIter->Next()) { - _PTR(SObject) aChildSObj = aIter->Value(); - CORBA::Object_var aChildObject = VISU::ClientSObjectToObject(aChildSObj); - - _PTR(GenericAttribute) anAttr; - if (aChildSObj->FindAttribute(anAttr, "AttributeComment")) { - _PTR(AttributeComment) aComment (anAttr); - string aComm = aComment->Value(); - QString strIn (aComm.c_str()); - VISU::Storable::TRestoringMap aMap; - VISU::Storable::StrToMap(strIn,aMap); - bool isExist; - VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); - if (isExist) { - if ((aType == VISU::TTIMESTAMP)) { - _PTR(GenericAttribute) aNameAttr; - if (aChildSObj->FindAttribute(aNameAttr, "AttributeName")) { - _PTR(AttributeName) aName (aNameAttr); - VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject); - QString aMeshName = VISU::getValue(aChildSObj,"myMeshName"); - if(QString(myPrs->GetMeshName().c_str()) != aMeshName) continue; - myCurrMeshName = aMeshName; - QString aFieldName = VISU::getValue(aChildSObj,"myFieldName"); - QString aTimeIter = VISU::getValue(aChildSObj,"myTimeStampId"); - QString aEntity = VISU::getValue(aChildSObj,"myEntityId"); - VISU::TEntity anEntity; - switch(aEntity.toInt()){ - case 0: anEntity = VISU::NODE_ENTITY; break; - case 1: anEntity = VISU::EDGE_ENTITY; break; - case 2: anEntity = VISU::FACE_ENTITY; break; - case 3: anEntity = VISU::CELL_ENTITY; break; - } - TFT &aFieldsMap = myMeshFieldsTimes[aMeshName.latin1()]; - TFE aKey(aFieldName.latin1(),anEntity); - aFieldsMap[aKey][aTimeIter.toInt()] = - GetFloatValueOfTimeStamp(myPrs->GetMeshName().c_str(), - aFieldName.latin1(), - aTimeIter.toInt(), - anEntity); - } - } - } - } - } } } - - AddAllFieldNames(); + if (mySelectionObj) { + _PTR(ChildIterator) aIter = aActiveStudy->NewChildIterator(mySelectionObj); + + for (aIter->InitEx(true); aIter->More(); aIter->Next()) { + _PTR(SObject) aChildSObj = aIter->Value(); + CORBA::Object_var aChildObject = VISU::ClientSObjectToObject(aChildSObj); + + _PTR(GenericAttribute) anAttr; + if (aChildSObj->FindAttribute(anAttr, "AttributeComment")) { + _PTR(AttributeComment) aComment (anAttr); + string aComm = aComment->Value(); + QString strIn (aComm.c_str()); + VISU::Storable::TRestoringMap aMap; + VISU::Storable::StrToMap(strIn,aMap); + bool isExist; + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if (isExist) { + if ((aType == VISU::TTIMESTAMP)) { + _PTR(GenericAttribute) aNameAttr; + if (aChildSObj->FindAttribute(aNameAttr, "AttributeName")) { + _PTR(AttributeName) aName (aNameAttr); + VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject); + QString aMeshName = VISU::getValue(aChildSObj, "myMeshName"); + if (QString(myPrs->GetMeshName().c_str()) != aMeshName) continue; + myCurrMeshName = aMeshName; + QString aFieldName = VISU::getValue(aChildSObj, "myFieldName"); + QString aTimeIter = VISU::getValue(aChildSObj, "myTimeStampId"); + QString aEntity = VISU::getValue(aChildSObj, "myEntityId"); + VISU::TEntity anEntity; + switch (aEntity.toInt()) { + case 0: anEntity = VISU::NODE_ENTITY; break; + case 1: anEntity = VISU::EDGE_ENTITY; break; + case 2: anEntity = VISU::FACE_ENTITY; break; + case 3: anEntity = VISU::CELL_ENTITY; break; + } + TFT &aFieldsMap = myMeshFieldsTimes[aMeshName.latin1()]; + TFE aKey (aFieldName.latin1(), anEntity); + aFieldsMap[aKey][aTimeIter.toInt()] = + GetFloatValueOfTimeStamp(myPrs->GetMeshName().c_str(), + aFieldName.latin1(), + aTimeIter.toInt(), + anEntity); + } + } + } + } + } + } + + AddAllFieldNames(); } myFieldsCombo->setCurrentText(aFieldName); AddAllTimes(myFieldsCombo->currentText()); @@ -282,11 +289,12 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject (VISU::ScalarMapOnDe myScalarPane->initFromPrsObject(myPrs); } -int VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs,bool theUpdateScalars, int theIter) { - if(MYDEBUG) cout << "VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject:"<<__LINE__<SetScale(getFactor()); - - if(myIsAnimation) + + if (myIsAnimation) thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(), getCurrentScalarFieldName().latin1(), theIter, @@ -294,7 +302,7 @@ int VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject(VISU::ScalarMapOnDefor else thePrs->SetScalarField(myPrs->GetScalarMeshName().c_str(), getCurrentScalarFieldName().latin1(), - myTimeStampsCombo->currentItem()+1, + myTimeStampsCombo->currentItem() + 1, myPrs->GetScalarEntity()); if (theUpdateScalars) SetScalarField(); @@ -302,7 +310,7 @@ int VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject(VISU::ScalarMapOnDefor thePrs->ShowColored(true); myScalarPane->storeToPrsObject(thePrs); - + myPrs = thePrs; return 1; diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx index aba09d66..e6fa3cc2 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx @@ -82,8 +82,7 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule) connect(myUseSrcCombo, SIGNAL(activated(int)), this, SLOT(onSourceTypeChange(int))); - // Find All prs obj - //SUIT_Study* aActiveStudy = VISU::(myVisuGUI); + // Find all fields and time stamps on it _PTR(Study) aActiveStudy = VISU::GetCStudy(VISU::GetAppStudy(myVisuGUI)); LightApp_SelectionMgr* aSel = VISU::GetSelectionMgr(myVisuGUI); SALOME_ListIO selected; @@ -92,71 +91,114 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule) Handle(SALOME_InteractiveObject) aIO = selected.First(); if (aIO->hasEntry()) { _PTR(SObject) aSObject = aActiveStudy->FindObjectID(aIO->getEntry()); + + _PTR(GenericAttribute) anTmpAttr; + if (aSObject->FindAttribute(anTmpAttr, "AttributeComment")) { + _PTR(AttributeComment) aTmpComment (anTmpAttr); + string aTmpComm = aTmpComment->Value(); + QString aTmpstrIn (aTmpComm.c_str()); + VISU::Storable::TRestoringMap aTmpaMap; + VISU::Storable::StrToMap(aTmpstrIn,aTmpaMap); + bool aTmpisExist; + VISU::VISUType aTmpType = + (VISU::VISUType)VISU::Storable::FindValue(aTmpaMap,"myType",&aTmpisExist).toInt(); + switch (aTmpType) { + case VISU::TTIMESTAMP: + { + aSObject = aSObject->GetFather(); + aSObject = aSObject->GetFather(); + break; + } + case VISU::TFIELD: + { + _PTR(SObject) newSObject; + if(aSObject->ReferencedObject(newSObject)) aSObject = newSObject; + aSObject = aSObject->GetFather(); + break; + } + case VISU::TANIMATION: + { + _PTR(ChildIterator) aTmpIter = aActiveStudy->NewChildIterator(aSObject); + for (aTmpIter->InitEx(true); aTmpIter->More(); aTmpIter->Next()) { + _PTR(SObject) aTmpChildSObj = aTmpIter->Value(); + _PTR(SObject) newSObject; + if(aTmpChildSObj->ReferencedObject(newSObject)){ + aSObject = newSObject; + aSObject->GetFather(); + break; + } + } + break; + } + } + } + aSObject = aSObject->GetFather(); aSObject = aSObject->GetFather(); - aSObject = aSObject->GetFather(); - aSObject = aSObject->GetFather(); + mySelectionObj = aSObject; CORBA::Object_var anObject = VISU::ClientSObjectToObject(mySelectionObj); - VISU::Result_var aResult; if (CORBA::is_nil(anObject)) { mySelectionObj = mySelectionObj->GetFather(); } - _PTR(ChildIterator) aIter = aActiveStudy->NewChildIterator(mySelectionObj); - - for (aIter->InitEx(true); aIter->More(); aIter->Next()) { - _PTR(SObject) aChildSObj = aIter->Value(); - CORBA::Object_var aChildObject = VISU::ClientSObjectToObject(aChildSObj); - - if (!CORBA::is_nil(aChildObject)) { - VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject); - if (!CORBA::is_nil(aPrsObj)) { // if this is a Prs object - if ((aPrsObj->GetType() != VISU::TSTREAMLINES) && - (aPrsObj->GetType() != VISU::TMESH)) { - _PTR(GenericAttribute) anAttr; - if (aChildSObj->FindAttribute(anAttr, "AttributeName")) { - _PTR(AttributeName) aName (anAttr); - myPrsLst += QString(aName->Value().c_str()); - myPrsList.append(aPrsObj); - continue; - } - } - } - } - // else { // This is not a Prs object - _PTR(GenericAttribute) anAttr; - if (aChildSObj->FindAttribute(anAttr, "AttributeComment")) { - _PTR(AttributeComment) aComment (anAttr); - string aComm = aComment->Value(); - QString strIn (aComm.c_str()); - VISU::Storable::TRestoringMap aMap; - VISU::Storable::StrToMap(strIn,aMap); - bool isExist; - VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); - if (isExist) { - if ((aType == VISU::TFAMILY) || (aType == VISU::TGROUP) || (aType == VISU::TENTITY)) { - _PTR(GenericAttribute) aNameAttr; - if (aChildSObj->FindAttribute(aNameAttr, "AttributeName")) { - _PTR(AttributeName) aName (aNameAttr); - VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject); - switch (aType) { - case VISU::TFAMILY: - myFamilisLst += QString(aName->Value().c_str()); - myFamilyList.append(aPrsObj); - break; - case VISU::TGROUP: - myGroupsLst += QString(aName->Value().c_str()); - myGroupList.append(aPrsObj); - break; - case VISU::TENTITY: - myEntitiesLst += QString(aName->Value().c_str()); - myEntityList.append(aPrsObj); - break; - } - } - } - } - } + } + } + + if (mySelectionObj) { + _PTR(ChildIterator) aIter = aActiveStudy->NewChildIterator(mySelectionObj); + + for (aIter->InitEx(true); aIter->More(); aIter->Next()) { + _PTR(SObject) aChildSObj = aIter->Value(); + CORBA::Object_var aChildObject = VISU::ClientSObjectToObject(aChildSObj); + + if (!CORBA::is_nil(aChildObject)) { + VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject); + if (!CORBA::is_nil(aPrsObj)) { // if this is a Prs object + if ((aPrsObj->GetType() != VISU::TSTREAMLINES) && + (aPrsObj->GetType() != VISU::TMESH)) { + _PTR(GenericAttribute) anAttr; + if (aChildSObj->FindAttribute(anAttr, "AttributeName")) { + _PTR(AttributeName) aName (anAttr); + myPrsLst += QString(aName->Value().c_str()); + myPrsList.append(aPrsObj); + continue; + } + } + } + } + + _PTR(GenericAttribute) anAttr; + if (aChildSObj->FindAttribute(anAttr, "AttributeComment")) { + _PTR(AttributeComment) aComment (anAttr); + string aComm = aComment->Value(); + QString strIn (aComm.c_str()); + VISU::Storable::TRestoringMap aMap; + VISU::Storable::StrToMap(strIn,aMap); + bool isExist; + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if (isExist) { + if ((aType == VISU::TFAMILY) || (aType == VISU::TGROUP) || (aType == VISU::TENTITY)) { + _PTR(GenericAttribute) aNameAttr; + if (aChildSObj->FindAttribute(aNameAttr, "AttributeName")) { + _PTR(AttributeName) aName (aNameAttr); + VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow(aChildObject); + switch (aType) { + case VISU::TFAMILY: + myFamilisLst += QString(aName->Value().c_str()); + myFamilyList.append(aPrsObj); + break; + case VISU::TGROUP: + myGroupsLst += QString(aName->Value().c_str()); + myGroupList.append(aPrsObj); + break; + case VISU::TENTITY: + myEntitiesLst += QString(aName->Value().c_str()); + myEntityList.append(aPrsObj); + break; + } + } + } + } } } } @@ -244,7 +286,6 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule) } - void VisuGUI_StreamLinesDlg::initFromPrsObject (VISU::StreamLines_i* thePrs) { myScalarPane->initFromPrsObject(thePrs); -- 2.39.2