From: apo Date: Fri, 21 Sep 2007 09:57:36 +0000 (+0000) Subject: Fix for Bug IPAL17020 X-Git-Tag: V4_1_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eb7eb234d72fff3ca059d189d25f79ba611cc8c2;p=modules%2Fvisu.git Fix for Bug IPAL17020 CRASH after calling "ApplyProperties()". --- diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index e533280f..74ab36c1 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -1691,7 +1691,8 @@ module VISU { * 5) the field name is not the same; * 6) the entity is not the same. */ - void ApplyProperties(in long theFieldNum, in ColoredPrs3d thePrs); + void ApplyProperties(in long theFieldNum, in ColoredPrs3d thePrs) + raises (SALOME::SALOME_Exception); }; diff --git a/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx b/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx index 0c40d8e2..e1dace81 100644 --- a/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx +++ b/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx @@ -129,6 +129,14 @@ VisuGUI_BuildProgressDlg::VisuGUI_BuildProgressDlg( QWidget* theParent ): myBuildFieldsButton->setPaletteBackgroundColor( Qt::red ); connect( myBuildFieldsCheckBox, SIGNAL( clicked() ), this, SLOT( onBuildCheckBoxClicked() ) ); + myBuildMinMaxCheckBox = new QCheckBox( tr( "BUILD_MINMAX" ), myProgressBox ); + myBuildMinMaxCheckBox->setChecked( aResourceMgr->booleanValue( "VISU", "build_min_max", true ) ); + myBuildMinMaxButton = new QPushButton( myProgressBox ); + myBuildMinMaxButton->setEnabled( false ); + myBuildMinMaxButton->setFixedSize( 30, 30 ); + myBuildMinMaxButton->setPaletteBackgroundColor( Qt::red ); + connect( myBuildMinMaxCheckBox, SIGNAL( clicked() ), this, SLOT( onBuildCheckBoxClicked() ) ); + myBuildGroupsCheckBox = new QCheckBox( tr( "BUILD_GROUPS" ), myProgressBox ); myBuildGroupsCheckBox->setChecked( aResourceMgr->booleanValue( "VISU", "build_groups", true ) ); myBuildGroupsButton = new QPushButton( myProgressBox ); @@ -141,8 +149,10 @@ VisuGUI_BuildProgressDlg::VisuGUI_BuildProgressDlg( QWidget* theParent ): aProgressLayout->addWidget( myBuildEntitiesButton, 0, 1 ); aProgressLayout->addWidget( myBuildFieldsCheckBox, 1, 0 ); aProgressLayout->addWidget( myBuildFieldsButton, 1, 1 ); - aProgressLayout->addWidget( myBuildGroupsCheckBox, 2, 0 ); - aProgressLayout->addWidget( myBuildGroupsButton, 2, 1 ); + aProgressLayout->addWidget( myBuildMinMaxCheckBox, 2, 0 ); + aProgressLayout->addWidget( myBuildMinMaxButton, 2, 1 ); + aProgressLayout->addWidget( myBuildGroupsCheckBox, 3, 0 ); + aProgressLayout->addWidget( myBuildGroupsButton, 3, 1 ); // Time myTimeBox = new QGroupBox( tr( "IMPORT_TIME" ), this ); @@ -222,7 +232,7 @@ void VisuGUI_BuildProgressDlg::onStart() tr("BUT_OK")); onClose(); }else{ - myResult->SetBuildFields( myBuildFieldsCheckBox->isChecked(), true ); + myResult->SetBuildFields( myBuildFieldsCheckBox->isChecked(), myBuildMinMaxCheckBox->isChecked() ); myResult->SetBuildGroups( myBuildGroupsCheckBox->isChecked() ); //setModal( false ); @@ -309,7 +319,8 @@ void VisuGUI_BuildProgressDlg::onTimer() bool isGroupsDone = myResult->IsGroupsDone(); updateButton( myBuildEntitiesButton, isEntitiesDone ); - updateButton( myBuildFieldsButton, isFieldsDone && isMinMaxDone); + updateButton( myBuildFieldsButton, isFieldsDone ); + updateButton( myBuildMinMaxButton, isMinMaxDone ); updateButton( myBuildGroupsButton, isGroupsDone ); } @@ -395,6 +406,14 @@ void VisuGUI_BuildProgressDlg::onBuildCheckBoxClicked() else if( aCheckBox == myBuildFieldsCheckBox ) { myBuildFieldsButton->setPaletteBackgroundColor( aColor ); + if( !anIsChecked && myBuildMinMaxCheckBox->isChecked() ) + myBuildMinMaxCheckBox->animateClick(); + } + else if( aCheckBox == myBuildMinMaxCheckBox ) + { + myBuildMinMaxButton->setPaletteBackgroundColor( aColor ); + if( anIsChecked && !myBuildFieldsCheckBox->isChecked() ) + myBuildFieldsCheckBox->animateClick(); } else if( aCheckBox == myBuildGroupsCheckBox ) myBuildGroupsButton->setPaletteBackgroundColor( aColor ); diff --git a/src/VISUGUI/VisuGUI_BuildProgressDlg.h b/src/VISUGUI/VisuGUI_BuildProgressDlg.h index 3eb7c1a1..8284c52d 100644 --- a/src/VISUGUI/VisuGUI_BuildProgressDlg.h +++ b/src/VISUGUI/VisuGUI_BuildProgressDlg.h @@ -95,6 +95,9 @@ private: QCheckBox* myBuildFieldsCheckBox; QPushButton* myBuildFieldsButton; + QCheckBox* myBuildMinMaxCheckBox; + QPushButton* myBuildMinMaxButton; + QCheckBox* myBuildGroupsCheckBox; QPushButton* myBuildGroupsButton; diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 0cf43b54..abb75081 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -809,21 +809,21 @@ namespace TDialog* aDlg = new TDialog(theModule); TPrs3d* aPrs3d = dynamic_cast(theData.myPrs[0]); aDlg->initFromPrsObject(aPrs3d, true); - if (aDlg->exec() && aDlg->storeToPrsObject(dynamic_cast(theData.myPrs[0]))) { + if (aDlg->exec() && aDlg->storeToPrsObject(dynamic_cast(aPrs3d))) { for (long aFrameId = 1; aFrameId < theData.myNbFrames; aFrameId++){ - VISU::ColoredPrs3d_i* aPrs3d = theData.myPrs[aFrameId]; - aPrs3d->SameAs(theData.myPrs[0]); + VISU::ColoredPrs3d_i* aColoredPrs3d = theData.myPrs[aFrameId]; + aColoredPrs3d->SameAs(aPrs3d); } if ( theAnimator->getAnimationMode() == VISU::Animation::SUCCESSIVE ) { for (int aFieldId = 1; aFieldId < theAnimator->getNbFields(); aFieldId++) { FieldData& aFieldData = theAnimator->getFieldData(aFieldId); for (long aFrameId = 0; aFrameId < aFieldData.myNbFrames; aFrameId++) { - VISU::ColoredPrs3d_i* aPrs3d = aFieldData.myPrs[aFrameId]; - std::string aTitle = aPrs3d->GetCTitle(); - aPrs3d->SameAs(theData.myPrs[0]); - aPrs3d->SetTitle(aTitle.c_str()); + VISU::ColoredPrs3d_i* aColoredPrs3d = aFieldData.myPrs[aFrameId]; + std::string aTitle = aColoredPrs3d->GetCTitle(); + aColoredPrs3d->SameAs(aPrs3d); + aColoredPrs3d->SetTitle(aTitle.c_str()); } } } diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 8c15a55c..ce1d5d92 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -77,6 +77,19 @@ namespace //--------------------------------------------------------------- namespace VISU { + //--------------------------------------------------------------- + inline + TMinMax + GetMinMax(VISU::Result_i* theResult, + VISU::PField theField, + vtkIdType theCompID) + { + if(!theResult->IsMinMaxDone()) + theResult->GetInput()->BuildMinMax(); + + return theField->GetMinMax(theCompID); + } + //--------------------------------------------------------------- vtkFloatingPointType TMinMaxController @@ -98,19 +111,20 @@ namespace VISU //--------------------------------------------------------------- struct TSimpleMinMaxController: virtual TVTKMinMaxController { + VISU::Result_i* myResult; VISU::PField myField; - TSimpleMinMaxController(VISU::PField theField) - { - myField = theField; - } + TSimpleMinMaxController(VISU::ColoredPrs3d_i* theColoredPrs3d): + myResult(theColoredPrs3d->GetCResult()), + myField(theColoredPrs3d->GetField()) + {} virtual vtkFloatingPointType GetComponentMin(vtkIdType theCompID) { if(myField){ - TMinMax aMinMax = myField->GetMinMax(theCompID); + TMinMax aMinMax = GetMinMax(myResult, myField, theCompID); return aMinMax.first; } return TMinMaxController::GetComponentMin(theCompID); @@ -121,7 +135,7 @@ namespace VISU GetComponentMax(vtkIdType theCompID) { if(myField){ - TMinMax aMinMax = myField->GetMinMax(theCompID); + TMinMax aMinMax = GetMinMax(myResult, myField, theCompID); return aMinMax.second; } return TMinMaxController::GetComponentMax(theCompID); @@ -133,8 +147,7 @@ namespace VISU PMinMaxController CreateDefaultMinMaxController(VISU::ColoredPrs3d_i* theColoredPrs3d) { - PField aField = theColoredPrs3d->GetScalarField(); - return PMinMaxController(new TSimpleMinMaxController(aField)); + return PMinMaxController(new TSimpleMinMaxController(theColoredPrs3d)); } @@ -773,7 +786,7 @@ VISU::ColoredPrs3d_i if(PMinMaxController aMinMaxController = GetMinMaxController()) return aMinMaxController->GetComponentMin(theCompID); - TMinMax aTMinMax = GetField()->GetMinMax(theCompID); + TMinMax aTMinMax = GetMinMax(GetCResult(), GetField(), theCompID); return aTMinMax.first; } @@ -785,7 +798,7 @@ VISU::ColoredPrs3d_i if(PMinMaxController aMinMaxController = GetMinMaxController()) return aMinMaxController->GetComponentMax(theCompID); - TMinMax aTMinMax = GetField()->GetMinMax(theCompID); + TMinMax aTMinMax = GetMinMax(GetCResult(), GetField(), theCompID); return aTMinMax.second; } diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 0804801c..15e1b06c 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -64,6 +64,8 @@ #include "SALOMEDSClient_AttributeName.hxx" #include "CASCatch.hxx" +#include "Utils_ExceptHandlers.hxx" + #include #include #include @@ -1783,19 +1785,24 @@ void VISU_TimeAnimation::onViewDeleted() void VISU_TimeAnimation::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) throw (SALOME::SALOME_Exception) { + Unexpect aCatch(SALOME_SalomeException); + VISU::ColoredPrs3d_i* aPrs_i = dynamic_cast(GetServant(thePrs).in()); if ( !aPrs_i ) - throw SALOME_Exception(LOCALIZED("Error : invalid dynamic cast of the given presentation to VISU::ColoredPrs3d_i")); + THROW_SALOME_CORBA_EXCEPTION("Error : invalid dynamic cast of the given presentation to VISU::ColoredPrs3d_i", + SALOME::INTERNAL_ERROR); if ( myAnimationMode == VISU::Animation::PARALLEL ) { // parallel animation mode FieldData& aData = myFieldsLst[theFieldNum]; if ( aData.myPrs.empty() ) - throw SALOME_Exception(LOCALIZED("Error : presentations for the given field is not yet created!")); + THROW_SALOME_CORBA_EXCEPTION("Error : presentations for the given field is not yet created!", + SALOME::INTERNAL_ERROR); if ( aPrs_i->GetCResult() != aData.myPrs[0]->GetCResult() ) - throw SALOME_Exception(LOCALIZED("Error : the MED file is not the same!")); + THROW_SALOME_CORBA_EXCEPTION("Error : the MED file is not the same!", + SALOME::INTERNAL_ERROR); for (int i = 0; i < aData.myNbFrames; i++) { bool anIsFixedRange = false; @@ -1811,7 +1818,8 @@ void VISU_TimeAnimation::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredP FieldData& aData = myFieldsLst[f]; if ( aData.myPrs.empty() ) - throw SALOME_Exception(LOCALIZED("Error : presentations for the given field is not yet created!")); + THROW_SALOME_CORBA_EXCEPTION("Error : presentations for the given field is not yet created!", + SALOME::INTERNAL_ERROR); for (int i = 0; i < aData.myNbFrames; i++) { aData.myPrs[i]->SameAs(aPrs_i);