From: apo Date: Fri, 7 Sep 2007 13:04:43 +0000 (+0000) Subject: Fix for Bug NPAL16764 - EDF 553 VISU : X-Git-Tag: T_24092007~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=405a5f7e0b6448731d9177fbfbfb3f4dd26f2c7b;p=modules%2Fvisu.git Fix for Bug NPAL16764 - EDF 553 VISU : In Animation Bad range by default in Scalarmap --- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index ce94a925..bb318663 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -3030,7 +3030,6 @@ void VisuGUI::createPreferences() addPreference( tr( "Full MED loading" ), importGr, LightApp_Preferences::Bool, "VISU", "full_med_loading" ); addPreference( tr( "Build at once" ), importGr, LightApp_Preferences::Bool, "VISU", "build_at_once" ); addPreference( tr( "Build fields" ), importGr, LightApp_Preferences::Bool, "VISU", "build_fields" ); - addPreference( tr( "Build min/max" ), importGr, LightApp_Preferences::Bool, "VISU", "build_min_max" ); addPreference( tr( "Build groups" ), importGr, LightApp_Preferences::Bool, "VISU", "build_groups" ); addPreference( tr( "Close dialog at finish" ), importGr, LightApp_Preferences::Bool, "VISU", "close_at_finish" ); diff --git a/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx b/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx index c1c9988d..e96c89c9 100644 --- a/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx +++ b/src/VISUGUI/VisuGUI_BuildProgressDlg.cxx @@ -129,14 +129,6 @@ 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 ); @@ -149,10 +141,8 @@ VisuGUI_BuildProgressDlg::VisuGUI_BuildProgressDlg( QWidget* theParent ): aProgressLayout->addWidget( myBuildEntitiesButton, 0, 1 ); aProgressLayout->addWidget( myBuildFieldsCheckBox, 1, 0 ); aProgressLayout->addWidget( myBuildFieldsButton, 1, 1 ); - aProgressLayout->addWidget( myBuildMinMaxCheckBox, 2, 0 ); - aProgressLayout->addWidget( myBuildMinMaxButton, 2, 1 ); - aProgressLayout->addWidget( myBuildGroupsCheckBox, 3, 0 ); - aProgressLayout->addWidget( myBuildGroupsButton, 3, 1 ); + aProgressLayout->addWidget( myBuildGroupsCheckBox, 2, 0 ); + aProgressLayout->addWidget( myBuildGroupsButton, 2, 1 ); // Time myTimeBox = new QGroupBox( tr( "IMPORT_TIME" ), this ); @@ -232,7 +222,7 @@ void VisuGUI_BuildProgressDlg::onStart() tr("BUT_OK")); onClose(); }else{ - myResult->SetBuildFields( myBuildFieldsCheckBox->isChecked(), myBuildMinMaxCheckBox->isChecked() ); + myResult->SetBuildFields( myBuildFieldsCheckBox->isChecked(), true ); myResult->SetBuildGroups( myBuildGroupsCheckBox->isChecked() ); //setModal( false ); @@ -313,8 +303,7 @@ void VisuGUI_BuildProgressDlg::onTimer() bool isGroupsDone = myResult->IsGroupsDone(); updateButton( myBuildEntitiesButton, isEntitiesDone ); - updateButton( myBuildFieldsButton, isFieldsDone ); - updateButton( myBuildMinMaxButton, isMinMaxDone ); + updateButton( myBuildFieldsButton, isFieldsDone && isMinMaxDone); updateButton( myBuildGroupsButton, isGroupsDone ); } @@ -400,14 +389,6 @@ 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 8284c52d..3eb7c1a1 100644 --- a/src/VISUGUI/VisuGUI_BuildProgressDlg.h +++ b/src/VISUGUI/VisuGUI_BuildProgressDlg.h @@ -95,9 +95,6 @@ private: QCheckBox* myBuildFieldsCheckBox; QPushButton* myBuildFieldsButton; - QCheckBox* myBuildMinMaxCheckBox; - QPushButton* myBuildMinMaxButton; - QCheckBox* myBuildGroupsCheckBox; QPushButton* myBuildGroupsButton; diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 9bed7266..3060c851 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -59,7 +59,10 @@ using namespace std; VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref): - QVBox(parent), myPreviewActor(0) + QVBox(parent), + myPreviewActor(0), + myScalarMap(NULL), + myScalarMapPL(NULL) { SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); QString propertyName; @@ -75,9 +78,6 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref): myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); - Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0; - myRangeMode = -1; - setSpacing(6); //setMargin(11); @@ -636,27 +636,6 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::PrsMerger_i* thePrs) { myOnGroupsCB->setChecked(true); } - // - myTitle = thePrs->GetTitle(); - setPosAndSize( thePrs->GetPosX(), - thePrs->GetPosY(), - thePrs->GetWidth(), - thePrs->GetHeight(), - thePrs->GetBarOrientation()); - switch(thePrs->GetScaling()){ - case VISU::LOGARITHMIC : - setLogarithmic(true); - break; - default: - setLogarithmic(false); - } - vtkFloatingPointType aRange[2]; - thePrs->GetPrsMergerPL()->GetSourceRange(aRange); - Rmin = aRange[0]; Rmax = aRange[1]; - setRange( thePrs->GetMin(), thePrs->GetMax(), - /*0.0, 0.0,*/ thePrs->IsRangeFixed() ); - setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() ); - // Update myModeCombo int aNbComp = thePrs->GetField()->myNbComp; bool isScalarMode = (aNbComp > 1); @@ -680,15 +659,36 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::PrsMerger_i* thePrs) { myModeCombo->insertItem(aComponent); } + // myModeCombo->setCurrentItem(thePrs->GetScalarMode()); - if (aNbComp==1){ + if (aNbComp == 1) myModeCombo->setCurrentItem(1); - } + // myModeLbl->setEnabled(isScalarMode); myModeCombo->setEnabled(isScalarMode); + switch(thePrs->GetScaling()){ + case VISU::LOGARITHMIC : + setLogarithmic(true); + break; + default: + setLogarithmic(false); + } + + setRange( thePrs->GetMin(), thePrs->GetMax(), thePrs->IsRangeFixed() ); + + setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() ); + + // + myTitle = thePrs->GetTitle(); + setPosAndSize( thePrs->GetPosX(), + thePrs->GetPosY(), + thePrs->GetWidth(), + thePrs->GetHeight(), + thePrs->GetBarOrientation()); + // "Title" myTextDlg->setTitleText(QString(thePrs->GetTitle())); @@ -1034,37 +1034,15 @@ void VisuGUI_ScalarBarPane::changeDefaults( int ) */ void VisuGUI_ScalarBarPane::changeRange( int ) { - int mode = -1; - if ( RBFrange->isChecked() ) - mode = 0; - if ( RBIrange->isChecked() ) - mode = 1; - if ( myRangeMode == mode ) - return; - //MinSpin->setMaxValue( Fmin ); - //MaxSpin->setMinValue( Fmax ); if ( RBFrange->isChecked() ) { - //MinLabel->setEnabled( false ); MinEdit->setEnabled( false ); - //MaxLabel->setEnabled( false ); MaxEdit->setEnabled( false ); - if ( mode != -1 ) { - Imin = MinEdit->text().toDouble(); - Imax = MaxEdit->text().toDouble(); - } - MinEdit->setText( QString::number( Rmin ) ); - MaxEdit->setText( QString::number( Rmax ) ); - } - else { - //MinLabel->setEnabled( true ); + } else { MinEdit->setEnabled( true ); - //MaxLabel->setEnabled( true ); MaxEdit->setEnabled( true ); - MinEdit->setText( QString::number( Imin ) ); - MaxEdit->setText( QString::number( Imax ) ); } - myRangeMode = mode; - updatePreview(); + + changeScalarMode(myModeCombo->currentItem()); } /*! @@ -1089,12 +1067,10 @@ void VisuGUI_ScalarBarPane::changeScalarMode( int theMode ) { if ( myScalarMap ) { if ( RBFrange->isChecked() ) { - vtkFloatingPointType aRange[2]; int aMode = myScalarMap->GetScalarMode(); myScalarMap->SetScalarMode(theMode); - myScalarMap->GetPrsMergerPL()->GetSourceRange(aRange); - MinEdit->setText( QString::number( aRange[0] ) ); - MaxEdit->setText( QString::number( aRange[1] ) ); + MinEdit->setText( QString::number( myScalarMap->GetSourceMin() ) ); + MaxEdit->setText( QString::number( myScalarMap->GetSourceMax() ) ); myScalarMap->SetScalarMode(aMode); } } @@ -1106,29 +1082,15 @@ void VisuGUI_ScalarBarPane::changeScalarMode( int theMode ) */ void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange ) { - Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax; - if ( RBIrange->isChecked() ) { - MinEdit->setText( QString::number( Imin ) ); - MaxEdit->setText( QString::number( Imax ) ); - } - else { - MinEdit->setText( QString::number( Rmin ) ); - MaxEdit->setText( QString::number( Rmax ) ); - } - myRangeMode = -1; + MinEdit->setText( QString::number( imin ) ); + MaxEdit->setText( QString::number( imax ) ); + if( sbRange ) RBIrange->setChecked( true ); else RBFrange->setChecked( true ); - changeRange( 0 ); -} -/*! - Sets default values and range mode -*/ -void VisuGUI_ScalarBarPane::setDefaultRange(double imin, double imax){ - Rmin = imin; - Rmax = imax; + changeRange( 0 ); } /*! @@ -1190,33 +1152,21 @@ bool VisuGUI_ScalarBarPane::check() } // check if logarithmic mode is on and check imposed range to not contain negative values if ( CBLog->isChecked() ) { - if ( RBIrange->isChecked() ) { - if ( (minVal > 0) && (maxVal > 0) ) { - // nothing to do - } - else { + if ( minVal <= 0.0 || maxVal <= 0.0 ) { + if ( RBIrange->isChecked() ) { SUIT_MessageBox::warn1( this, - tr("WRN_VISU"), - tr("WRN_LOGARITHMIC_RANGE"), - tr("BUT_OK")); - return false; - } - } - else { - if ( Rmin > 0 && Rmax > 0 ) { - // nothing to do - } - else { + tr("WRN_VISU"), + tr("WRN_LOGARITHMIC_RANGE"), + tr("BUT_OK")); + } else { SUIT_MessageBox::warn1( this, - tr("WRN_VISU"), - tr("WRN_LOGARITHMIC_FIELD_RANGE"), - tr("BUT_OK")); - RBIrange->setChecked(1); + tr("WRN_VISU"), + tr("WRN_LOGARITHMIC_FIELD_RANGE"), + tr("BUT_OK")); + RBIrange->setChecked(true); changeRange(1); - //MinEdit->setText( QString::number( Rmin ) ); - //MaxEdit->setText( QString::number( Rmax ) ); - return false; } + return false; } } return true; diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h index 404e0653..9426ba2d 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -184,10 +184,8 @@ class VisuGUI_ScalarBarPane : public QVBox QPushButton* myTextBtn; VisuGUI_TextPrefDlg* myTextDlg; - double Imin, Imax, /* Fmin, Fmax,*/ Rmin, Rmax; double myHorX, myHorY, myHorW, myHorH; double myVerX, myVerY, myVerW, myVerH; - int myRangeMode; bool myIsStoreTextProp; private slots: diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 47b4f711..02f5ce66 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -782,6 +782,14 @@ VISU::ColoredPrs3d_i return myField; } +CORBA::Boolean +VISU::ColoredPrs3d_i +::IsTimeStampFixed() +{ + SALOMEDS::SObject_var aSObject = GetSObject(); + return !CORBA::is_nil(aSObject); +} + const std::string& VISU::ColoredPrs3d_i ::GetMeshName() const diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 6b493ac2..0fd4e6d1 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -172,6 +172,10 @@ namespace VISU virtual const VISU::PField& GetField() const; + virtual + CORBA::Boolean + IsTimeStampFixed(); + const std::string& GetMeshName() const; diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index ba047590..a0e3f460 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -311,6 +311,7 @@ VISU::ScalarMap_i myScalarMapPL->SetMapScale(theMapScale); } +//---------------------------------------------------------------------------- bool VISU::ScalarMap_i ::IsRangeFixed() @@ -318,14 +319,54 @@ VISU::ScalarMap_i return myIsFixedRange; } +//---------------------------------------------------------------------------- void VISU::ScalarMap_i ::SetSourceRange() { - myScalarMapPL->SetSourceRange(); + if(IsTimeStampFixed()){ + ProcessVoidEvent(new TVoidMemFunEvent + (myScalarMapPL, &VISU_ScalarMapPL::SetSourceRange)); + }else{ + TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode()); + vtkFloatingPointType aScalarRange[2] = {aTMinMax.first, aTMinMax.second}; + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myScalarMapPL, &VISU_ScalarMapPL::SetScalarRange, aScalarRange)); + } + myIsFixedRange = false; } +//---------------------------------------------------------------------------- +CORBA::Double +VISU::ScalarMap_i +::GetSourceMin() +{ + if(IsTimeStampFixed()){ + vtkFloatingPointType aRange[2]; + myScalarMapPL->GetSourceRange(aRange); + return aRange[0]; + }else{ + TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode()); + return aTMinMax.first; + } +} + +//---------------------------------------------------------------------------- +CORBA::Double +VISU::ScalarMap_i +::GetSourceMax() +{ + if(IsTimeStampFixed()){ + vtkFloatingPointType aRange[2]; + myScalarMapPL->GetSourceRange(aRange); + return aRange[1]; + }else{ + TMinMax aTMinMax = GetField()->GetMinMax(GetScalarMode()); + return aTMinMax.second; + } +} + //---------------------------------------------------------------------------- VISU_Actor* VISU::ScalarMap_i diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index ef29f65f..16d6490e 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -144,6 +144,14 @@ namespace VISU void SetSourceRange(); + virtual + CORBA::Double + GetSourceMin(); + + virtual + CORBA::Double + GetSourceMax(); + virtual void SameAs(const Prs3d_i* theOrigin); diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 574c940b..dea9e8c5 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -366,7 +366,7 @@ namespace aPresent->_remove_ref(); } theData.myNbFrames = aFrameId; - + /* if (theData.myPrsType != VISU::TGAUSSPOINTS){ int aRangeType = VISU::GetResourceMgr()->integerValue("VISU" , "scalar_range_type", 0); if( aRangeType != 1 ){ @@ -382,6 +382,7 @@ namespace if (VISU::IsoSurfaces_i* aPrs = dynamic_cast(theData.myPrs[aFrameId])) aPrs->SetSubRange(aMin, aMax); } + */ } } @@ -1527,13 +1528,12 @@ SALOMEDS::SObject_ptr VISU_TimeAnimation::publishInStudy() for (int i = 0; i < getNbFields(); i++) { FieldData& aData = myFieldsLst[i]; - if ( aData.myPrs.front() ) { + if (aData.myPrs.empty()) + generatePresentations(i); + if ( !aData.myPrs.empty() ) { _PTR(SObject) newObj = aStudyBuilder->NewObject(aAnimSObject); aStudyBuilder->Addreference(newObj, aData.myField); - if (aData.myPrs.empty()) { - generatePresentations(i); - } ostringstream strOut; aData.myPrs[0]->ToStream(strOut); string aPrsComment = strOut.str();