From 286f2831e94ba6b4a9d7bd2ba58a0c478f466e95 Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 1 Jun 2007 13:03:22 +0000 Subject: [PATCH] Fix for Bug IPAL16080 - IOLS. Impossible to display and edit presentations created in 3x --- src/VISUGUI/VisuGUI_InputPane.cxx | 4 +- .../VisuGUI_ScalarMapOnDeformedShapeDlg.cxx | 130 ++++++++---------- .../VisuGUI_ScalarMapOnDeformedShapeDlg.h | 17 +-- src/VISUGUI/VisuGUI_Slider.cxx | 6 +- src/VISU_I/VISU_ColoredPrs3dHolder_i.cc | 4 +- src/VISU_I/VISU_ColoredPrs3dHolder_i.hh | 2 +- src/VISU_I/VISU_ColoredPrs3d_i.cc | 20 +-- src/VISU_I/VISU_ColoredPrs3d_i.hh | 2 +- src/VISU_I/VISU_DumpPython.cc | 12 +- 9 files changed, 93 insertions(+), 104 deletions(-) diff --git a/src/VISUGUI/VisuGUI_InputPane.cxx b/src/VISUGUI/VisuGUI_InputPane.cxx index 1ee34f36..776d8d59 100644 --- a/src/VISUGUI/VisuGUI_InputPane.cxx +++ b/src/VISUGUI/VisuGUI_InputPane.cxx @@ -447,12 +447,12 @@ void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) clear(); CORBA::Long aTimeStampNumber = thePrs->GetTimeStampNumber(); - VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = thePrs->GetTimeStampsRange(); + VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange = thePrs->GetTimeStampsRange(); CORBA::Long aLength = aTimeStampsRange->length(); for( int index = 0; index < aLength; index++ ) { - VISU::ColoredPrs3d::TimeStampInfo anInfo = aTimeStampsRange[ index ]; + VISU::ColoredPrs3dHolder::TimeStampInfo anInfo = aTimeStampsRange[ index ]; QString aTime = anInfo.myTime.in(); myTimeStamps->insertItem( aTime ); } diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx index 9d8d0fe7..482f8c57 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx @@ -173,18 +173,13 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject(VISU::ColoredPrs3d_i setFactor(myPrsCopy->GetScale()); myTimeStampsCombo->setDisabled(myIsAnimation); - myCurrMeshName = myPrsCopy->GetCMeshName(); - CORBA::String_var aMeshName = myPrsCopy->GetMeshName(); - CORBA::String_var aFieldName(myPrsCopy->GetScalarCFieldName()); - float aIterFloat = GetFloatValueOfTimeStamp(aMeshName.in(), + CORBA::String_var aFieldName(myPrsCopy->GetScalarFieldName()); + QString aIteration = GetFloatValueOfTimeStamp(myPrsCopy->GetScalarEntity(), aFieldName.in(), - myPrsCopy->GetScalarLIteration(), - myPrsCopy->GetScalarEEntity()); - QString aIteration(QString("%1").arg(aIterFloat)); - - if (myMeshFieldsTimes.size() == 0) + myPrsCopy->GetScalarTimeStampNumber()); + if (myEntity2Fields.size() == 0) { // find all fields and time stamps on it _PTR(Study) aActiveStudy = VISU::GetCStudy(VISU::GetAppStudy(myVisuGUI)); @@ -271,7 +266,6 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject(VISU::ColoredPrs3d_i CORBA::String_var aName = myPrsCopy->GetMeshName(); if (aMeshName != aName.in()) continue; - myCurrMeshName = aMeshName; QString aFieldName = VISU::getValue(aChildSObj, "myFieldName"); QString aTimeIter = VISU::getValue(aChildSObj, "myTimeStampId"); QString aEntity = VISU::getValue(aChildSObj, "myEntityId"); @@ -282,13 +276,12 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject(VISU::ColoredPrs3d_i case 2: anEntity = VISU::FACE; break; case 3: anEntity = VISU::CELL; break; } - TFT &aFieldsMap = myMeshFieldsTimes[aMeshName.latin1()]; - TFE aKey (aFieldName.latin1(), anEntity); - aFieldsMap[aKey][aTimeIter.toInt()] = - GetFloatValueOfTimeStamp(aMeshName.latin1(), - aFieldName.latin1(), - aTimeIter.toInt(), - anEntity); + TFieldName2TimeStamps& aFieldName2TimeStamps = myEntity2Fields[anEntity]; + TTimeStampNumber2Time& aTimeStampNumber2Time = aFieldName2TimeStamps[aFieldName]; + aTimeStampNumber2Time[aTimeIter.toInt()] = + GetFloatValueOfTimeStamp(anEntity, + aFieldName.latin1(), + aTimeIter.toInt()); } } } @@ -324,11 +317,9 @@ VisuGUI_ScalarMapOnDeformedShapeDlg myPrsCopy->SetScale(getFactor()); - CORBA::String_var aMeshName = myPrsCopy->GetMeshName(); - myPrsCopy->SetScalarField(aMeshName.in(), + myPrsCopy->SetScalarField(myPrsCopy->GetScalarEntity(), getCurrentScalarFieldName().latin1(), - myTimeStampID[ myTimeStampsCombo->currentItem() ], - myPrsCopy->GetScalarEEntity()); + myTimeStampID[ myTimeStampsCombo->currentItem() ]); if(myUpdateScalars) SetScalarField( false ); @@ -354,12 +345,17 @@ VISU::Entity VisuGUI_ScalarMapOnDeformedShapeDlg ::getCurrentScalarEntity() { - VISU::Entity anEntity; - TFT::const_iterator aIterField = myMeshFieldsTimes[myCurrMeshName].begin(); - for(;aIterField != myMeshFieldsTimes[myCurrMeshName].end();aIterField++){ - if (aIterField->first.first == myFieldsCombo->currentText()){ - anEntity = aIterField->first.second; - break; + VISU::Entity anEntity = VISU::Entity(-1); + TEntity2Fields::const_iterator anIter = myEntity2Fields.begin(); + for(; anIter != myEntity2Fields.end(); anIter++){ + const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second; + TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin(); + for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){ + const QString& aFieldName = aFieldIter->first; + if (aFieldName == myFieldsCombo->currentText()) { + anEntity = anIter->first; + break; + } } } return anEntity; @@ -387,10 +383,9 @@ VisuGUI_ScalarMapOnDeformedShapeDlg VISU::Entity anEntity = getCurrentScalarEntity(); - myPrsCopy->SetScalarField(myCurrMeshName.latin1(), + myPrsCopy->SetScalarField(anEntity, aFieldName.latin1(), - theIter, - anEntity); + theIter); if( save_scalar_pane ) UpdateScalarField(); @@ -431,32 +426,38 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::onHelp() } void VisuGUI_ScalarMapOnDeformedShapeDlg::AddAllFieldNames(){ - TMF::const_iterator aIterMesh = myMeshFieldsTimes.begin(); - for(;aIterMesh != myMeshFieldsTimes.end();aIterMesh++){ - QString aMeshName = aIterMesh->first; - TFT::const_iterator aIterField = (aIterMesh->second).begin(); - for(;aIterField != (aIterMesh->second).end(); aIterField++){ - QString aFieldName = aIterField->first.first; + TEntity2Fields::const_iterator anIter = myEntity2Fields.begin(); + for(; anIter != myEntity2Fields.end(); anIter++){ + const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second; + TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin(); + for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){ + const QString& aFieldName = aFieldIter->first; myFieldsCombo->insertItem(aFieldName); } } } void VisuGUI_ScalarMapOnDeformedShapeDlg::AddAllTimes(const QString& theFieldName){ - TMF::const_iterator aIterMesh = myMeshFieldsTimes.begin(); - for(;aIterMesh != myMeshFieldsTimes.end();aIterMesh++){ - QString aMeshName = aIterMesh->first; - TFT::const_iterator aIterField = (aIterMesh->second).begin(); - for(;aIterField != (aIterMesh->second).end(); aIterField++){ - QString aFieldName = aIterField->first.first; - if(theFieldName != aFieldName) continue; - myTimeStampsCombo->clear(); + TEntity2Fields::const_iterator anIter = myEntity2Fields.begin(); + for(; anIter != myEntity2Fields.end(); anIter++){ + const TFieldName2TimeStamps& aFieldName2TimeStamps = anIter->second; + TFieldName2TimeStamps::const_iterator aFieldIter = aFieldName2TimeStamps.begin(); + for(; aFieldIter != aFieldName2TimeStamps.end(); aFieldIter++){ + const QString& aFieldName = aFieldIter->first; + if(theFieldName != aFieldName) + continue; + myTimeStampID.clear(); - myTimeStampID.reserve( (aIterField->second).size() ); - TTL::const_iterator aTimeIter = (aIterField->second).begin(); - for(;aTimeIter != (aIterField->second).end(); aTimeIter++) { - myTimeStampsCombo->insertItem(QString("%1").arg(aTimeIter->second)); - myTimeStampID.push_back(aTimeIter->first); + myTimeStampsCombo->clear(); + + const TTimeStampNumber2Time& aTimeStampNumber2Time = aFieldIter->second; + TTimeStampNumber2Time::const_iterator aTimeStampIter = aTimeStampNumber2Time.begin(); + for(; aTimeStampIter != aTimeStampNumber2Time.end(); aTimeStampIter++){ + int aTimeStampNumber = aTimeStampIter->first; + myTimeStampID.push_back(aTimeStampNumber); + + QString aTimeStampTime = aTimeStampIter->second; + myTimeStampsCombo->insertItem(aTimeStampTime); } return; } @@ -478,38 +479,29 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::UpdateScalarField(){ myScalarPane->initFromPrsObject(myPrsCopy); } -float +QString VisuGUI_ScalarMapOnDeformedShapeDlg -::GetFloatValueOfTimeStamp(const char* theMeshName, - const char* theFieldName, - const int theIter, - const VISU::Entity theEntity) +::GetFloatValueOfTimeStamp(VISU::Entity theEntity, + const std::string& theFieldName, + int theTimeStampNumber) { - float ret=1; + QString aTime(""); VISU::TEntity anEntity = VISU::TEntity(theEntity); VISU::Result_i* theResult = myPrsCopy->GetCResult(); VISU::Result_i::TInput* anInput = theResult->GetInput(); - VISU::PField aField = anInput->GetField(theMeshName, + VISU::PField aField = anInput->GetField(myPrsCopy->GetCMeshName(), anEntity, theFieldName); if(!aField) - return ret; + return aTime; + VISU::TValField& aValField = aField->myValField; - VISU::TValField::const_iterator aIter = aValField.find(theIter); + VISU::TValField::const_iterator aIter = aValField.find(theTimeStampNumber); if(aIter != aValField.end()){ VISU::PValForTime aValForTime = aIter->second; - ret = float(aValForTime->myTime.first); - } else { - if(MYDEBUG){ - cout << "Where are no aValForTime with iteration:"<first << ","; - cout << endl; - } + aTime = VISU_Convertor::GenerateName(aValForTime->myTime).c_str(); } - return ret; + return aTime; } void VisuGUI_ScalarMapOnDeformedShapeDlg::keyPressEvent( QKeyEvent* e ) diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h index e6178bcd..3ccd052b 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h @@ -95,13 +95,11 @@ private: QComboBox *myFieldsCombo; QComboBox *myTimeStampsCombo; - typedef std::map TTL; // Times map definition (iteration time, real value of time) - typedef std::pair TFE; // pair field name and entity - typedef std::map TFT; // Field name and enity to Times - typedef std::map TMF; // Mesh to fields map + typedef std::map TTimeStampNumber2Time; // Times map definition (iteration time, real value of time) + typedef std::map TFieldName2TimeStamps; // Field name and enity to Times + typedef std::map TEntity2Fields; // Mesh to fields map - TMF myMeshFieldsTimes; - QString myCurrMeshName; + TEntity2Fields myEntity2Fields; int myCurrScalarIter; bool myIsAnimation; bool myUpdateScalars; @@ -116,10 +114,9 @@ protected: void SetScalarField( const bool = true ); void AddAllFieldNames(); void AddAllTimes(const QString& theFieldName); - float GetFloatValueOfTimeStamp(const char* theMeshName, - const char* theFieldName, - const int theIteration, - const VISU::Entity theEntity); + QString GetFloatValueOfTimeStamp(VISU::Entity theEntity, + const std::string& theFieldName, + int theTimeStampNumber); }; #endif // VISUGUI_DEFORMEDSHAPEDLS_H diff --git a/src/VISUGUI/VisuGUI_Slider.cxx b/src/VISUGUI/VisuGUI_Slider.cxx index fbc6cc00..fe6cf3eb 100644 --- a/src/VISUGUI/VisuGUI_Slider.cxx +++ b/src/VISUGUI/VisuGUI_Slider.cxx @@ -250,7 +250,7 @@ void VisuGUI_Slider::enableControls( bool on ) VISU::ColoredPrs3dHolder_var aHolder = myHolderList.front(); - VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = aHolder->GetTimeStampsRange(); + VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange = aHolder->GetTimeStampsRange(); CORBA::Long aLength = aTimeStampsRange->length(); VISU::ColoredPrs3dHolder::BasicInput_var anInput = aHolder->GetBasicInput(); @@ -267,7 +267,7 @@ void VisuGUI_Slider::enableControls( bool on ) CORBA::Long a_current_index = 0; for( CORBA::Long an_index = 0; an_index < aLength; an_index++ ) { - VISU::ColoredPrs3d::TimeStampInfo anInfo = aTimeStampsRange[ an_index ]; + VISU::ColoredPrs3dHolder::TimeStampInfo anInfo = aTimeStampsRange[ an_index ]; CORBA::Long aNumber = anInfo.myNumber; QString aTime = anInfo.myTime.in(); @@ -413,7 +413,7 @@ void VisuGUI_Slider::onValueChanged( int value ) VISU::ColoredPrs3dHolder_var aHolder = myHolderList.front(); - VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = aHolder->GetTimeStampsRange(); + VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange = aHolder->GetTimeStampsRange(); CORBA::Long aLength = aTimeStampsRange->length(); if(value < 0 || aLength <= value) return; diff --git a/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc b/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc index 5f543b34..1adcba4d 100644 --- a/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dHolder_i.cc @@ -163,11 +163,11 @@ VISU::ColoredPrs3dHolder_i //---------------------------------------------------------------------------- -VISU::ColoredPrs3d::TimeStampsRange* +VISU::ColoredPrs3dHolder::TimeStampsRange* VISU::ColoredPrs3dHolder_i ::GetTimeStampsRange() { - if( VISU::ColoredPrs3d_ptr aDevice = GetDevice() ) + if( VISU::ColoredPrs3d_i* aDevice = GetPrs3dDevice() ) return aDevice->GetTimeStampsRange(); return NULL; diff --git a/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh b/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh index 2434272c..bdf2c2da 100644 --- a/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3dHolder_i.hh @@ -79,7 +79,7 @@ namespace VISU //---------------------------------------------------------------------------- //! Gets TimeStampsRange information from the last visited presentation. virtual - VISU::ColoredPrs3d::TimeStampsRange* + VISU::ColoredPrs3dHolder::TimeStampsRange* GetTimeStampsRange(); //---------------------------------------------------------------------------- diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 8824261f..1fa8df8a 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -284,12 +284,12 @@ CORBA::Long VISU::ColoredPrs3d_i ::GetTimeStampNumberByIndex( CORBA::Long theIndex ) { - VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = GetTimeStampsRange(); + VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange = GetTimeStampsRange(); CORBA::Long aLength = aTimeStampsRange->length(); if( theIndex >= 0 && theIndex < aLength ) { - VISU::ColoredPrs3d::TimeStampInfo anInfo = aTimeStampsRange[ theIndex ]; + VISU::ColoredPrs3dHolder::TimeStampInfo anInfo = aTimeStampsRange[ theIndex ]; return anInfo.myNumber; } @@ -302,12 +302,12 @@ CORBA::Long VISU::ColoredPrs3d_i ::GetTimeStampIndexByNumber( CORBA::Long theNumber ) { - VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = GetTimeStampsRange(); + VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange = GetTimeStampsRange(); CORBA::Long aLength = aTimeStampsRange->length(); for( int index = 0; index < aLength; index++ ) { - VISU::ColoredPrs3d::TimeStampInfo anInfo = aTimeStampsRange[ index ]; + VISU::ColoredPrs3dHolder::TimeStampInfo anInfo = aTimeStampsRange[ index ]; if( anInfo.myNumber == theNumber ) return index; @@ -336,17 +336,18 @@ VISU::ColoredPrs3d_i //---------------------------------------------------------------------------- -VISU::ColoredPrs3d::TimeStampsRange* +VISU::ColoredPrs3dHolder::TimeStampsRange* VISU::ColoredPrs3d_i ::GetTimeStampsRange() { - VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = new VISU::ColoredPrs3d::TimeStampsRange(); + VISU::ColoredPrs3dHolder::TimeStampsRange_var aTimeStampsRange = + new VISU::ColoredPrs3dHolder::TimeStampsRange(); VISU::TValField& aValField = GetField()->myValField; if(IsTimeStampFixed()){ aTimeStampsRange->length(1); PValForTime& aValForTime = aValField[GetTimeStampNumber()]; std::string aTime = VISU_Convertor::GenerateName(aValForTime->myTime); - VISU::ColoredPrs3d::TimeStampInfo anInfo; + VISU::ColoredPrs3dHolder::TimeStampInfo anInfo; anInfo.myNumber = GetTimeStampNumber(); anInfo.myTime = aTime.c_str(); aTimeStampsRange[0] = anInfo; @@ -385,7 +386,7 @@ VISU::ColoredPrs3d_i for(size_t aCounter = 0; anIter != aSortedRange.end(); anIter++, aCounter++){ vtkIdType aTimeStampNumber = anIter->first; const std::string& aTime = anIter->second; - VISU::ColoredPrs3d::TimeStampInfo anInfo; + VISU::ColoredPrs3dHolder::TimeStampInfo anInfo; anInfo.myNumber = aTimeStampNumber; anInfo.myTime = aTime.c_str(); aTimeStampsRange[aCounter] = anInfo; @@ -1166,7 +1167,7 @@ VISU::ColoredPrs3d_i SetEntity((VISU::Entity)VISU::Storable::FindValue(theMap,"myEntity").toInt()); SetFieldName(VISU::Storable::FindValue(theMap,"myFieldName").latin1()); SetTimeStampNumber(VISU::Storable::FindValue(theMap,"myIteration").toInt()); - myIsTimeStampFixed = VISU::Storable::FindValue(theMap,"myIsTimeStampFixed").toInt(); + myIsTimeStampFixed = VISU::Storable::FindValue(theMap,"myIsTimeStampFixed", "1").toInt(); OnSetInput(false); Build(ERestore); @@ -1330,6 +1331,7 @@ VISU::ColoredPrs3d_i throw; } #endif + if(anIsPublishInStudy) aStudyBuilder->CommitCommand(); return this; diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index a255c6a6..30e68db6 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -111,7 +111,7 @@ namespace VISU GetScalarTimeStampNumber() const; virtual - VISU::ColoredPrs3d::TimeStampsRange* + VISU::ColoredPrs3dHolder::TimeStampsRange* GetTimeStampsRange(); virtual diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index bc2ed067..4ab275e6 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -788,7 +788,7 @@ namespace VISU theStr<GetScale()<<")"<GetScalarEEntity(); + VISU::Entity anEntity = aServant->GetScalarEntity(); switch(anEntity){ case NODE: aParam = "VISU.NODE"; @@ -804,15 +804,13 @@ namespace VISU break; } - CORBA::String_var aMeshName = aServant->GetScalarCMeshName(); - CORBA::String_var aFieldName = aServant->GetScalarCFieldName(); - CORBA::Long aTimeStampNumber = aServant->GetScalarLIteration(); + CORBA::String_var aFieldName = aServant->GetScalarFieldName(); + CORBA::Long aTimeStampNumber = aServant->GetScalarTimeStampNumber(); theStr<