]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug IPAL17020
authorapo <apo@opencascade.com>
Fri, 21 Sep 2007 09:57:36 +0000 (09:57 +0000)
committerapo <apo@opencascade.com>
Fri, 21 Sep 2007 09:57:36 +0000 (09:57 +0000)
   CRASH after calling "ApplyProperties()".

idl/VISU_Gen.idl
src/VISUGUI/VisuGUI_BuildProgressDlg.cxx
src/VISUGUI/VisuGUI_BuildProgressDlg.h
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_TimeAnimation.cxx

index e533280ff73ac8ebb9b5310e19d0f33acc89e4d2..74ab36c1951756980bebd1c98ae15058717b799d 100644 (file)
@@ -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);
   };
 
   
index 0c40d8e2daa6c8ab81c97e3659fb6f6e68933412..e1dace81abd4b1f2f8a1956f3fe1d8097a0dee97 100644 (file)
@@ -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 );
index 3eb7c1a100cc63410976e7345e766c314a5229c5..8284c52df99f15c9f709c2bc9d5f075b566ac573 100644 (file)
@@ -95,6 +95,9 @@ private:
   QCheckBox*       myBuildFieldsCheckBox;
   QPushButton*     myBuildFieldsButton;
 
+  QCheckBox*       myBuildMinMaxCheckBox;
+  QPushButton*     myBuildMinMaxButton;
+
   QCheckBox*       myBuildGroupsCheckBox;
   QPushButton*     myBuildGroupsButton;
 
index 0cf43b54d3ba58b73372d14003c639cdf795be4d..abb75081d02a5bf91b7334e0788682c3e1f456c0 100644 (file)
@@ -809,21 +809,21 @@ namespace
     TDialog* aDlg = new TDialog(theModule);
     TPrs3d* aPrs3d = dynamic_cast<TPrs3d*>(theData.myPrs[0]);
     aDlg->initFromPrsObject(aPrs3d, true);
-    if (aDlg->exec() && aDlg->storeToPrsObject(dynamic_cast<TPrs3d*>(theData.myPrs[0]))) {
+    if (aDlg->exec() && aDlg->storeToPrsObject(dynamic_cast<TPrs3d*>(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());
          }
        }
       }
index 8c15a55c0aed16e40c21c2f552d084eb957b0d64..ce1d5d921c14ee63e193e88e02ad2ec2cb29d57e 100644 (file)
@@ -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;
 }
 
index 0804801c6a6980bdf56be3e455533395ce2e8ec2..15e1b06ccb8b4b17f850f2dca7abfd3bce08f2a2 100644 (file)
@@ -64,6 +64,8 @@
 #include "SALOMEDSClient_AttributeName.hxx"
 #include "CASCatch.hxx"
 
+#include "Utils_ExceptHandlers.hxx"
+
 #include <qpixmap.h>
 #include <qimage.h>
 #include <qstrlist.h>
@@ -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<VISU::ColoredPrs3d_i*>(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);