From: apo Date: Thu, 11 Sep 2008 07:06:51 +0000 (+0000) Subject: Improving "Filtering by Scalars" functionality X-Git-Tag: TG_VISU_2008_2008-09-12~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=296ed3686b78042e10dd285adde0ec23adc92ff6;p=modules%2Fvisu.git Improving "Filtering by Scalars" functionality --- diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index f068b4ef..ddabec98 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -554,7 +554,6 @@ module VISU { */ Orientation GetBarOrientation(); - // RKV : Begin /*! * Set the visibility of a distribution curve. * \param theIs is used to switch on/off the visibility of a distribution curve. @@ -565,7 +564,9 @@ module VISU { boolean GetIsDistributionVisible(); //! Gets current filtering by scalars mode - boolean IsFilteredByScalars(); + boolean IsScalarFilterUsed(); + + void UseScalarFiltering( in boolean theUseScalarFilter ); /*! * Sets scalar range - min and max boundaries of the scalar bar. @@ -573,9 +574,11 @@ module VISU { * \param theMax Max boundary of the scalar bar. * \param theIsFilter if true then filter by scalars. */ - void SetRangeAndFilter(in double theMin, in double theMax, in boolean theIsFilter); + void SetScalarFilterRange( in double theMin, in double theMax ); + + double GetScalarFilterMin(); - // RKV : End + double GetScalarFilterMax(); /*! * Add group as geometry of presentation. diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index dbe0955f..6dd93b81 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -225,7 +225,8 @@ CreateColoredPL(VISU_Convertor* theConvertor, cout << "before filter limits set" << endl; vtkObject::GlobalWarningDisplayOn(); aPresent->DebugOn(); - aPresent->SetScalarRange(aRange, true); + aPresent->SetScalarFilteredRange( aRange ); + aPresent->UseScalarFiltering( true ); cout << "after filter set" << endl; //aPresent->ClearGeometry(); diff --git a/src/PIPELINE/VISU_ColoredPL.cxx b/src/PIPELINE/VISU_ColoredPL.cxx index dc046b8f..3c01e1bd 100644 --- a/src/PIPELINE/VISU_ColoredPL.cxx +++ b/src/PIPELINE/VISU_ColoredPL.cxx @@ -34,18 +34,21 @@ #include "VISU_PipeLineUtils.hxx" +#include +#include +#include + //---------------------------------------------------------------------------- VISU_ColoredPL ::VISU_ColoredPL(): - myMapperTable(VISU_LookupTable::New()), - myBarTable(VISU_LookupTable::New()), - myExtractor(VISU_Extractor::New()), - myFieldTransform(VISU_FieldTransform::New()), - myThreshold(vtkThreshold::New()), // RKV - myPassFilter(vtkPassThroughFilter::New()), // RKV - myDistribution(vtkDoubleArray::New()), // RKV - myIsFiltered(false) // RKV + myMapperTable( VISU_LookupTable::New() ), + myBarTable( VISU_LookupTable::New() ), + myExtractor( VISU_Extractor::New() ), + myFieldTransform( VISU_FieldTransform::New() ), + myThreshold ( vtkThreshold::New() ), + myPassFilter( vtkPassThroughFilter::New() ), + myDistribution( vtkDoubleArray::New() ) { myMapperTable->Delete(); myMapperTable->SetScale(VTK_SCALE_LINEAR); @@ -59,10 +62,10 @@ VISU_ColoredPL myFieldTransform->Delete(); - myThreshold->AllScalarsOn(); // RKV - myThreshold->Delete(); // RKV - myPassFilter->Delete(); // RKV - myDistribution->Delete(); // RKV + myThreshold->AllScalarsOn(); + myThreshold->Delete(); + myPassFilter->Delete(); + myDistribution->Delete(); } @@ -83,13 +86,9 @@ VISU_ColoredPL aTime = std::max(aTime, myBarTable->GetMTime()); aTime = std::max(aTime, myExtractor->GetMTime()); aTime = std::max(aTime, myFieldTransform->GetMTime()); - // RKV : Begin - if (IsFiltered()) { - aTime = std::max(aTime, myThreshold->GetMTime()); - } + aTime = std::max(aTime, myThreshold->GetMTime()); aTime = std::max(aTime, myPassFilter->GetMTime()); aTime = std::max(aTime, myDistribution->GetMTime()); - // RKV : End return aTime; } @@ -104,19 +103,23 @@ VISU_ColoredPL Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); if(VISU_ColoredPL *aPipeLine = dynamic_cast(thePipeLine)){ - if(theIsCopyInput) - SetScalarRange(aPipeLine->GetScalarRange(), aPipeLine->IsFiltered()); // RKV -// RKV SetScalarRange(aPipeLine->GetScalarRange()); + if ( theIsCopyInput ) { + SetScalarRange( aPipeLine->GetScalarRange() ); + if ( this->IsScalarFilterUsed() ) + SetScalarFilteredRange( aPipeLine->GetScalarFilteredRange() ); + } + SetScalarMode(aPipeLine->GetScalarMode()); SetNbColors(aPipeLine->GetNbColors()); SetScaling(aPipeLine->GetScaling()); SetMapScale(aPipeLine->GetMapScale()); - if(this != thePipeLine){ - if(aPipeLine->IsExternalGeometryUsed()){ + + if ( this != thePipeLine ) { + if ( aPipeLine->IsExternalGeometryUsed() ) { ClearGeometry(); int aNbOfGeometry = aPipeLine->GetNumberOfGeometry(); for(int aGeomNumber = 0; aGeomNumber < aNbOfGeometry; aGeomNumber++) - AddGeometry(aPipeLine->GetGeometry(aGeomNumber)); + AddGeometry( aPipeLine->GetGeometry( aGeomNumber ) ); }else SetSourceGeometry(); } @@ -169,48 +172,85 @@ VISU_ColoredPL SetScalarMode(theScalarMode, GetInput(), myExtractor); } + //---------------------------------------------------------------------------- -/* RKV void VISU_ColoredPL -::SetScalarRange(vtkFloatingPointType theRange[2]) +::SetScalarRange( vtkFloatingPointType theRange[2] ) { - if(theRange[0] > theRange[1]) + if ( theRange[0] > theRange[1] ) return; - if(VISU::CheckIsSameRange(GetScalarRange(), theRange)) + if (VISU::CheckIsSameRange( GetScalarRange(), theRange) ) return; - myFieldTransform->SetScalarRange(theRange); - myBarTable->SetRange(theRange); + myFieldTransform->SetScalarRange( theRange ); + myBarTable->SetRange( theRange ); } -*/ -// RKV : Begin + + +//---------------------------------------------------------------------------- void VISU_ColoredPL -::SetScalarRange(vtkFloatingPointType theRange[2], const bool isFiltered) +::SetScalarFilteredRange( vtkFloatingPointType theRange[2] ) { - // isFiltered - if true then drop cells which are not in the scalar range - if(theRange[0] > theRange[1]) - return; - - if(VISU::CheckIsSameRange(GetScalarRange(), theRange) && (myIsFiltered == isFiltered)) + vtkFloatingPointType aRange[ 2 ]; + this->GetScalarFilteredRange( aRange ); + + if ( VISU::CheckIsSameRange( aRange, theRange) ) return; - myFieldTransform->SetScalarRange(theRange); - myBarTable->SetRange(theRange); - myIsFiltered = isFiltered; - if (IsFiltered()) { + myThreshold->ThresholdBetween( theRange[0], theRange[1] ); +} + + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::GetScalarFilteredRange( vtkFloatingPointType theRange[2] ) +{ + theRange[ 0 ] = myThreshold->GetLowerThreshold(); + theRange[ 1 ] = myThreshold->GetUpperThreshold(); +} + + +//---------------------------------------------------------------------------- +vtkFloatingPointType* +VISU_ColoredPL +::GetScalarFilteredRange() +{ + static vtkFloatingPointType aRange[ 2 ]; + + this->GetScalarFilteredRange( aRange ); + + return aRange; +} + + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::UseScalarFiltering( bool theUseScalarFilter ) +{ + if ( theUseScalarFilter ) { // Include threshold filter between the transform and the pass filters. - myThreshold->SetInput(myFieldTransform->GetOutput()); - myThreshold->ThresholdBetween(theRange[0], theRange[1]); - myPassFilter->SetInput(myThreshold->GetOutput()); + myPassFilter->SetInput( myThreshold->GetOutput() ); } else { // Exclude threshold filter before the pass filter. - myPassFilter->SetInput(myFieldTransform->GetOutput()); + myPassFilter->SetInput( myFieldTransform->GetOutput() ); } } + +//---------------------------------------------------------------------------- +bool +VISU_ColoredPL +::IsScalarFilterUsed() +{ + return myThreshold->GetOutput() == myPassFilter->GetInput(); +} + + //---------------------------------------------------------------------------- vtkDoubleArray* VISU_ColoredPL @@ -329,7 +369,12 @@ VISU_ColoredPL ::Init() { SetScalarMode(0); - SetSourceRange(); + + vtkFloatingPointType aRange[2]; + GetSourceRange( aRange ); + + SetScalarRange( aRange ); + SetScalarFilteredRange( aRange ); } //---------------------------------------------------------------------------- @@ -356,11 +401,13 @@ void VISU_ColoredPL ::Build() { - myExtractor->SetInput(Superclass::GetClippedInput()); + myExtractor->SetInput( Superclass::GetClippedInput() ); myFieldTransform->SetInput(myExtractor->GetOutput()); + + myThreshold->SetInput( myFieldTransform->GetOutput() ); // The pass filter is used here for possibility to include/exclude // threshold filter before it. - myPassFilter->SetInput(myFieldTransform->GetOutput()); // RKV + myPassFilter->SetInput( myFieldTransform->GetOutput() ); GetMapperHolder()->SetLookupTable(GetMapperTable()); GetMapper()->SetUseLookupTableScalarRange(true); @@ -467,7 +514,7 @@ VISU_ColoredPL ::GetSourceRange(vtkFloatingPointType theRange[2]) { myExtractor->Update(); - myExtractor->GetOutput()->GetScalarRange(theRange); + myExtractor->GetOutput()->GetScalarRange( theRange ); } void @@ -475,7 +522,6 @@ VISU_ColoredPL ::SetSourceRange() { vtkFloatingPointType aRange[2]; - GetSourceRange(aRange); -// RKV SetScalarRange(aRange); - SetScalarRange(aRange, myIsFiltered); // RKV + GetSourceRange( aRange ); + SetScalarRange( aRange ); } diff --git a/src/PIPELINE/VISU_ColoredPL.hxx b/src/PIPELINE/VISU_ColoredPL.hxx index fe65499d..add4a36d 100644 --- a/src/PIPELINE/VISU_ColoredPL.hxx +++ b/src/PIPELINE/VISU_ColoredPL.hxx @@ -31,14 +31,16 @@ #include "VISU_PipeLine.hxx" #include -#include // RKV -#include // RKV -#include // RKV class VISU_Extractor; class VISU_FieldTransform; class VISU_LookupTable; +class vtkPassThroughFilter; +class vtkDoubleArray; +class vtkThreshold; + + //---------------------------------------------------------------------------- class VISU_ColoredPL : public VISU_PipeLine { @@ -64,8 +66,22 @@ public: virtual void - SetScalarRange(vtkFloatingPointType theRange[2], const bool isFiltered); // RKV -// RKV SetScalarRange(vtkFloatingPointType theRange[2]); + SetScalarRange( vtkFloatingPointType theRange[2] ); + + void + SetScalarFilteredRange( vtkFloatingPointType theRange[2] ); + + void + GetScalarFilteredRange( vtkFloatingPointType theRange[2] ); + + vtkFloatingPointType* + GetScalarFilteredRange(); + + bool + IsScalarFilterUsed(); + + void + UseScalarFiltering( bool theUseScalarFilter ); virtual void @@ -83,14 +99,11 @@ public: int GetNbColors(); -// RKV : Begin - //---------------------------------------------------------------------------- - bool IsFiltered() {return myIsFiltered;}; - - vtkDoubleArray* GetDistribution(); // RKV -// RKV : End - //---------------------------------------------------------------------------- + vtkDoubleArray* GetDistribution(); + + public: + //---------------------------------------------------------------------------- virtual void Init(); @@ -132,31 +145,31 @@ public: virtual void - SetSourceGeometry()=0; + SetSourceGeometry() = 0; virtual int - AddGeometry(vtkDataSet* theGeometry)=0; + AddGeometry(vtkDataSet* theGeometry) = 0; virtual vtkDataSet* - GetGeometry(int theGeomNumber)=0; + GetGeometry( int theGeomNumber ) = 0; virtual int - GetNumberOfGeometry()=0; + GetNumberOfGeometry() = 0; virtual bool - IsExternalGeometryUsed()=0; + IsExternalGeometryUsed() = 0; virtual void - ClearGeometry()=0; + ClearGeometry() = 0; virtual vtkPointSet* - GetMergedInput()=0; + GetMergedInput() = 0; protected: //---------------------------------------------------------------------------- @@ -196,14 +209,13 @@ protected: VISU_Extractor* theExtractor); private: - vtkSmartPointer myMapperTable; - vtkSmartPointer myBarTable; - vtkSmartPointer myExtractor; - vtkSmartPointer myFieldTransform; - vtkSmartPointer myThreshold; // RKV - vtkSmartPointer myPassFilter; // RKV - vtkSmartPointer myDistribution; // RKV - bool myIsFiltered; // RKV + vtkSmartPointer< VISU_LookupTable > myMapperTable; + vtkSmartPointer< VISU_LookupTable > myBarTable; + vtkSmartPointer< VISU_Extractor > myExtractor; + vtkSmartPointer< VISU_FieldTransform > myFieldTransform; + vtkSmartPointer< vtkThreshold > myThreshold; + vtkSmartPointer< vtkPassThroughFilter > myPassFilter; + vtkSmartPointer< vtkDoubleArray > myDistribution; }; #endif diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index c133cad4..66529bb9 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -114,11 +114,9 @@ VISU_IsoSurfacesPL //---------------------------------------------------------------------------- void VISU_IsoSurfacesPL -::SetScalarRange(vtkFloatingPointType theRange[2], const bool isFiltered) +::SetScalarRange( vtkFloatingPointType theRange[2] ) { -// RKV Superclass::SetScalarRange(theRange); -// Superclass::SetScalarRange(theRange, IsFiltered()); // RKV - Superclass::SetScalarRange(theRange, isFiltered); // VSV + Superclass::SetScalarRange( theRange ); SetRange(myRange); } diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.hxx b/src/PIPELINE/VISU_IsoSurfacesPL.hxx index 1e75ddd7..9d606f7e 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.hxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.hxx @@ -59,7 +59,7 @@ public: virtual void - SetScalarRange(vtkFloatingPointType theRange[2], const bool isFiltered); + SetScalarRange( vtkFloatingPointType theRange[2] ); virtual void diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 5ff2255d..d14f7765 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -200,7 +200,7 @@ number of time stamps or number of components is not the same! VISU_LOGARITHMIC_SCALING - Logarithmic scaling + Logarithmic VISU_MAX diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index c6ec2d9d..bc8b238e 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -3811,6 +3811,6 @@ void VisuGUI::OnMultiprChangeRes(VISU::Result::Resolution theResolution) void VisuGUI::OnFilterScalars() { - VisuGUI_FilterScalarsDlg* aDlg = new VisuGUI_FilterScalarsDlg(this); + VisuGUI_FilterScalarsDlg* aDlg = new VisuGUI_FilterScalarsDlg( this ); aDlg->show(); } diff --git a/src/VISUGUI/VisuGUI_FilterScalarsDlg.cxx b/src/VISUGUI/VisuGUI_FilterScalarsDlg.cxx index 8482b7b3..b606a41e 100644 --- a/src/VISUGUI/VisuGUI_FilterScalarsDlg.cxx +++ b/src/VISUGUI/VisuGUI_FilterScalarsDlg.cxx @@ -19,11 +19,14 @@ // #include "VisuGUI_FilterScalarsDlg.h" +#include "VISU_ColoredPrs3d_i.hh" #include "VisuGUI.h" #include "VisuGUI_Tools.h" -#include +#include +#include + #include #include #include @@ -38,9 +41,9 @@ #include -VisuGUI_FilterScalarsDlg::VisuGUI_FilterScalarsDlg(VisuGUI* theModule) +VisuGUI_FilterScalarsDlg::VisuGUI_FilterScalarsDlg( VisuGUI* theModule ) : QDialog(VISU::GetDesktop(theModule), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), - myVisuGUI(theModule) + myVisuGUI( theModule ) { setModal( false ); setWindowTitle(tr("TITLE")); @@ -49,19 +52,19 @@ VisuGUI_FilterScalarsDlg::VisuGUI_FilterScalarsDlg(VisuGUI* theModule) QVBoxLayout* aMainLayout = new QVBoxLayout(this); - QGroupBox* aRangeBox = new QGroupBox(this); - aRangeBox->setTitle(tr("BOXTITLE")); - aRangeBox->setCheckable(true); - aMainLayout->addWidget(aRangeBox); - - QHBoxLayout* aBoxLayout = new QHBoxLayout(aRangeBox); - aBoxLayout->addWidget(new QLabel(tr("MINLBL"), aRangeBox)); - myMinEdit = new QLineEdit( aRangeBox ); + myRangeBox = new QGroupBox(this); + myRangeBox->setTitle(tr("BOXTITLE")); + myRangeBox->setCheckable(true); + aMainLayout->addWidget(myRangeBox); + + QHBoxLayout* aBoxLayout = new QHBoxLayout(myRangeBox); + aBoxLayout->addWidget(new QLabel(tr("MINLBL"), myRangeBox)); + myMinEdit = new QLineEdit( myRangeBox ); myMinEdit->setValidator( new QDoubleValidator(myMinEdit) ); aBoxLayout->addWidget(myMinEdit); - aBoxLayout->addWidget(new QLabel(tr("MAXLBL"), aRangeBox)); - myMaxEdit = new QLineEdit( aRangeBox ); + aBoxLayout->addWidget(new QLabel(tr("MAXLBL"), myRangeBox)); + myMaxEdit = new QLineEdit( myRangeBox ); myMaxEdit->setValidator( new QDoubleValidator(myMaxEdit) ); aBoxLayout->addWidget(myMaxEdit); @@ -88,11 +91,43 @@ VisuGUI_FilterScalarsDlg::VisuGUI_FilterScalarsDlg(VisuGUI* theModule) connect(aBtnOk, SIGNAL(clicked()), this, SLOT(accept())); connect(aBtnCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(aBtnHelp, SIGNAL(clicked()), this, SLOT(onHelp())); + + SalomeApp_Application* anApp = theModule->getApp(); + LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr(); + connect( aSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionEvent() ) ); + + onSelectionEvent(); } +VisuGUI_FilterScalarsDlg::~VisuGUI_FilterScalarsDlg() +{} + +void VisuGUI_FilterScalarsDlg::onSelectionEvent() +{ + VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects( myVisuGUI ); + if ( !aSelectionInfo.empty() ) { + VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); + if ( VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase ) + if ( VISU::ColoredPrs3d_i* aColoredPrs3d = dynamic_cast< VISU::ColoredPrs3d_i* >( aBase ) ) { + myRangeBox->setChecked( aColoredPrs3d->IsScalarFilterUsed() ); + myMinEdit->setText( QString::number( aColoredPrs3d->GetScalarFilterMin() ) ); + myMaxEdit->setText( QString::number( aColoredPrs3d->GetScalarFilterMax() ) ); + myColoredPrs3d = aColoredPrs3d; + setEnabled( true ); + return; + } + } + typedef SALOME::GenericObjPtr< VISU::ColoredPrs3d_i > TColoredPrs3dPtr; + myColoredPrs3d = TColoredPrs3dPtr(); + setEnabled( false ); + return; +} + void VisuGUI_FilterScalarsDlg::accept() { + myColoredPrs3d->SetScalarFilterRange( myMinEdit->text().toDouble(), myMaxEdit->text().toDouble() ); + myColoredPrs3d->UseScalarFiltering( myRangeBox->isChecked() ); QDialog::accept(); } diff --git a/src/VISUGUI/VisuGUI_FilterScalarsDlg.h b/src/VISUGUI/VisuGUI_FilterScalarsDlg.h index fa9e2e04..fdbb1f2b 100644 --- a/src/VISUGUI/VisuGUI_FilterScalarsDlg.h +++ b/src/VISUGUI/VisuGUI_FilterScalarsDlg.h @@ -31,17 +31,26 @@ #include -class QLineEdit; +#include "SALOME_GenericObjPointer.hh" + class VisuGUI; +class QLineEdit; +class QGroupBox; + +namespace VISU +{ + class ColoredPrs3d_i; +} + class VisuGUI_FilterScalarsDlg: public QDialog { Q_OBJECT; public: - VisuGUI_FilterScalarsDlg(VisuGUI* theModule); - ~VisuGUI_FilterScalarsDlg() {}; + VisuGUI_FilterScalarsDlg( VisuGUI* theModule ); + ~VisuGUI_FilterScalarsDlg(); protected slots: @@ -51,10 +60,13 @@ protected slots: private slots: void onHelp(); + void onSelectionEvent(); private: VisuGUI* myVisuGUI; + SALOME::GenericObjPtr< VISU::ColoredPrs3d_i > myColoredPrs3d; + QGroupBox* myRangeBox; QLineEdit* myMinEdit; QLineEdit* myMaxEdit; }; diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx index 8d07bf99..f16cc52d 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -624,11 +624,6 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), aGB); CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); -// RKV : Begin - CBFilter = new QCheckBox (tr("FILTER_BY_SCALARS"), aGB); - CBFilter->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); -// RKV : End - RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), aGB); RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), aGB); RangeGroup->addButton( RBFrange, 0 ); @@ -641,6 +636,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) MinEdit->setValidator( new QDoubleValidator(this) ); MinEdit->setText( "0.0" ); QLabel* MinLabel = new QLabel (tr("LBL_MIN"), aGB); + MinLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); MinLabel->setBuddy(MinEdit); MaxEdit = new QLineEdit( aGB ); @@ -649,19 +645,18 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) MaxEdit->setValidator( new QDoubleValidator(this) ); MaxEdit->setText( "0.0" ); QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), aGB); + MaxLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); MaxLabel->setBuddy(MaxEdit); - RangeGroupLayout->addWidget( myModeLbl, 0, 0 ); - RangeGroupLayout->addWidget( myModeCombo, 0, 1, 1, 4); -// RKV RangeGroupLayout->addWidget( CBLog, 1, 0, 1, 4); - RangeGroupLayout->addWidget( CBLog, 1, 0, 1, 2); // RKV - RangeGroupLayout->addWidget( CBFilter, 1, 2, 1, 2); // RKV - RangeGroupLayout->addWidget( RBFrange, 2, 0, 1, 2); - RangeGroupLayout->addWidget( RBIrange, 2, 2, 1, 2); - RangeGroupLayout->addWidget( MinLabel, 3, 0 ); - RangeGroupLayout->addWidget( MinEdit, 3, 1 ); - RangeGroupLayout->addWidget( MaxLabel, 3, 2 ); - RangeGroupLayout->addWidget( MaxEdit, 3, 3 ); + RangeGroupLayout->addWidget( myModeLbl, 0, 0, 1, 1 ); + RangeGroupLayout->addWidget( myModeCombo, 0, 1, 1, 2); + RangeGroupLayout->addWidget( CBLog, 0, 3, 1, 1); + RangeGroupLayout->addWidget( RBFrange, 1, 0, 1, 2); + RangeGroupLayout->addWidget( RBIrange, 1, 2, 1, 2); + RangeGroupLayout->addWidget( MinLabel, 2, 0 ); + RangeGroupLayout->addWidget( MinEdit, 2, 1 ); + RangeGroupLayout->addWidget( MaxLabel, 2, 2 ); + RangeGroupLayout->addWidget( MaxEdit, 2, 3 ); //TopLayout->addWidget( RangeGroup ); @@ -845,7 +840,6 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane( QWidget* parent, bool thePreview ) connect( myBarBtn, SIGNAL( clicked() ), this, SLOT( onBarPref() ) ); connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) ); - connect( CBFilter, SIGNAL( toggled( bool ) ), this, SLOT( onFilterByScalars( bool ) )); // RKV connect( CBDistr, SIGNAL( toggled( bool ) ), this, SLOT( onShowDistribution( bool ) )); // RKV connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() )); @@ -918,7 +912,6 @@ void VisuGUI_ScalarBarPane::storeToResources() { aResourceMgr->setValue("VISU", "scalar_range_type", 0); aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic()); - aResourceMgr->setValue("VISU", "scalar_bar_filter_by_scalars", isFilteredByScalars()); // RKV aResourceMgr->setValue("VISU", "scalar_bar_show_distribution", isShowDistribution()); // RKV //// @@ -1057,11 +1050,7 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) setRange( myScalarMap->GetMin(), myScalarMap->GetMax(), myScalarMap->IsRangeFixed() ); setScalarBarData( myScalarMap->GetNbColors(), myScalarMap->GetLabels() ); -// RKV : Begin - setFilteredByScalars( myScalarMap->IsFilteredByScalars() ); setShowDistribution( myScalarMap->GetIsDistributionVisible() ); -// RKV : End - // "Title" CORBA::String_var aTitle = myScalarMap->GetTitle(); @@ -1171,25 +1160,22 @@ void VisuGUI_ScalarBarPane::createScalarBar() myScalarMapPL->SetScaling(VISU::LOGARITHMIC); else myScalarMapPL->SetScaling(VISU::LINEAR); - vtkFloatingPointType theRange[2]; - if(RBFrange->isChecked()) { - theRange[0] = myScalarMap->GetSourceMin(); - theRange[1] = myScalarMap->GetSourceMax(); + + if ( RBFrange->isChecked() ) { + myScalarMapPL->SetSourceRange(); } else { - theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble(); - theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble(); + vtkFloatingPointType aRange[2]; + aRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble(); + aRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble(); + myScalarMapPL->SetScalarRange( aRange ); } -// RKV myScalarMapPL->SetScalarRange(theRange, false); - myScalarMapPL->SetScalarRange(theRange, isFilteredByScalars()); // RKV - myScalarMapPL->SetNbColors(sbCol); - + + myScalarMapPL->SetNbColors(sbCol); myScalarMapPL->Update(); aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable()); -// RKV : Begin - aScalarBarActor->SetDistribution(myScalarMapPL->GetDistribution()); - aScalarBarActor->SetDistributionVisibility(isShowDistribution()); -// RKV : End + aScalarBarActor->SetDistribution( myScalarMapPL->GetDistribution() ); + aScalarBarActor->SetDistributionVisibility( isShowDistribution() ); if (!myTextDlg->getTitleText().isEmpty()) { VISU::PValForTime aValForTime; @@ -1323,11 +1309,10 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { else myScalarMap->SetScaling(VISU::LINEAR); - if (RBFrange->isChecked()) { + if ( RBFrange->isChecked() ) { myScalarMap->SetSourceRange(); } else { -// RKV myScalarMap->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble()); - myScalarMap->SetRangeAndFilter(MinEdit->text().toDouble(), MaxEdit->text().toDouble(), isFilteredByScalars()); // RKV + myScalarMap->SetRange( MinEdit->text().toDouble(), MaxEdit->text().toDouble() ); } myScalarMap->SetNbColors(ColorSpin->value()); myScalarMap->SetLabels(LabelSpin->value()); @@ -1412,7 +1397,6 @@ void VisuGUI_ScalarBarPane::onFieldRange( bool isOn ) myScalarMap->SetSourceRange(); MinEdit->setEnabled( false ); MaxEdit->setEnabled( false ); - CBFilter->setEnabled( false ); changeScalarMode(myModeCombo->currentIndex()); } } @@ -1420,40 +1404,29 @@ void VisuGUI_ScalarBarPane::onFieldRange( bool isOn ) void VisuGUI_ScalarBarPane::onImposedRange( bool isOn ) { if (isOn) { - myScalarMap->SetRange(myScalarMap->GetMin(), myScalarMap->GetMax()); - //myScalarMap->SetRangeAndFilter(myScalarMap->GetMin(), myScalarMap->GetMax(), isFilteredByScalars()); + myScalarMap->SetRange( myScalarMap->GetMin(), myScalarMap->GetMax() ); MinEdit->setEnabled( true ); MaxEdit->setEnabled( true ); - CBFilter->setEnabled( true ); changeScalarMode(myModeCombo->currentIndex()); } } -// RKV : Begin -void VisuGUI_ScalarBarPane::onFilterByScalars( bool isOn ) -{ - myScalarMap->SetRangeAndFilter(myScalarMap->GetMin(), myScalarMap->GetMax(), isOn); - updatePreview(); -} void VisuGUI_ScalarBarPane::onShowDistribution( bool isOn ) { myScalarMap->SetIsDistributionVisible(isOn); updatePreview(); } -// RKV : End + void VisuGUI_ScalarBarPane::changeRange( int ) { if ( RBFrange->isChecked() ) { myScalarMap->SetSourceRange(); MinEdit->setEnabled( false ); MaxEdit->setEnabled( false ); - CBFilter->setEnabled( false ); } else { - myScalarMap->SetRange(myScalarMap->GetMin(), myScalarMap->GetMax()); - //myScalarMap->SetRangeAndFilter(myScalarMap->GetMin(), myScalarMap->GetMax(), isFilteredByScalars()); + myScalarMap->SetRange( myScalarMap->GetMin(), myScalarMap->GetMax() ); MinEdit->setEnabled( true ); MaxEdit->setEnabled( true ); - CBFilter->setEnabled( true ); } changeScalarMode(myModeCombo->currentIndex()); @@ -1579,20 +1552,6 @@ void VisuGUI_ScalarBarPane::setLogarithmic( bool on ) { CBLog->setChecked( on ); } -// RKV : Begin -//---------------------------------------------------------------------------- -bool VisuGUI_ScalarBarPane::isFilteredByScalars() { - if (CBFilter->isEnabled()) - return CBFilter->isChecked(); - return false; -} - - -//---------------------------------------------------------------------------- -void VisuGUI_ScalarBarPane::setFilteredByScalars( bool on ) { - CBFilter->setChecked( on ); -} - //---------------------------------------------------------------------------- bool VisuGUI_ScalarBarPane::isShowDistribution() { return CBDistr->isChecked(); diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.h b/src/VISUGUI/VisuGUI_Prs3dDlg.h index 4923b626..01fefefd 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.h +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.h @@ -175,12 +175,8 @@ class VisuGUI_ScalarBarPane : public QWidget//QVBox int getNbLabels(); bool isLogarithmic(); void setLogarithmic( bool on ); - // RKV : Begin - bool isFilteredByScalars(); - void setFilteredByScalars( bool on ); bool isShowDistribution(); void setShowDistribution( bool on ); - // RKV : End bool isToSave(); void storeToResources(); @@ -211,10 +207,8 @@ class VisuGUI_ScalarBarPane : public QWidget//QVBox QCheckBox* CBSave; QCheckBox* CBLog; - // RKV : Begin - QCheckBox* CBFilter; QCheckBox* CBDistr; - // RKV : End + QLabel* myModeLbl; QComboBox* myModeCombo; QPushButton* myTextBtn; diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index cb97985f..04b34d9f 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -687,19 +687,21 @@ VISU::ColoredPrs3d_i SetNbColors(anOrigin->GetNbColors()); SetUnitsVisible(anOrigin->IsUnitsVisible()); - SetIsDistributionVisible(anOrigin->GetIsDistributionVisible()); // RKV + SetIsDistributionVisible(anOrigin->GetIsDistributionVisible()); SetLabelsFormat(anOrigin->GetLabelsFormat()); SetBarOrientation(anOrigin->GetBarOrientation()); SetMinMaxController( anOrigin ); - if(anOrigin->IsRangeFixed()) -// RKV SetRange(anOrigin->GetMin(), anOrigin->GetMax()); - SetRangeAndFilter(anOrigin->GetMin(), anOrigin->GetMax(), anOrigin->IsFilteredByScalars()); // RKV + if ( anOrigin->IsRangeFixed() ) + SetRange( anOrigin->GetMin(), anOrigin->GetMax() ); else SetSourceRange(); + SetScalarFilterRange( anOrigin->GetScalarFilterMin(), anOrigin->GetScalarFilterMax() ); + UseScalarFiltering( anOrigin->IsScalarFilterUsed() ); + SetPosition(anOrigin->GetPosX(), anOrigin->GetPosY()); SetSize(anOrigin->GetWidth(), anOrigin->GetHeight()); SetRatios(anOrigin->GetTitleWidth(), anOrigin->GetTitleHeight(), @@ -773,25 +775,74 @@ VISU::ColoredPrs3d_i return myColoredPL->GetScalarRange()[1]; } + //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i -::SetRange(CORBA::Double theMin, CORBA::Double theMax) +::SetRange( CORBA::Double theMin, CORBA::Double theMax ) { VISU::TSetModified aModified(this); vtkFloatingPointType aScalarRange[2] = {theMin, theMax}; -/* RKV ProcessVoidEvent(new TVoidMemFun2ArgEvent - (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange, false)); -*/ -// RKV : Begin - ProcessVoidEvent(new TVoidMemFun2ArgEvent - (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange, myColoredPL->IsFiltered())); -// RKV : End + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange)); UseFixedRange(true); } +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::SetScalarFilterRange( CORBA::Double theMin, CORBA::Double theMax ) +{ + VISU::TSetModified aModified(this); + + vtkFloatingPointType aScalarRange[ 2 ] = { theMin, theMax }; + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificPL(), &VISU_ColoredPL::SetScalarFilteredRange, aScalarRange) ); +} + + +//---------------------------------------------------------------------------- +CORBA::Double +VISU::ColoredPrs3d_i +::GetScalarFilterMin() +{ + vtkFloatingPointType aScalarRange[ 2 ]; + GetSpecificPL()->GetScalarFilteredRange( aScalarRange ); + + return aScalarRange[ 0 ]; +} + + +//---------------------------------------------------------------------------- +CORBA::Double +VISU::ColoredPrs3d_i +::GetScalarFilterMax() +{ + vtkFloatingPointType aScalarRange[ 2 ]; + GetSpecificPL()->GetScalarFilteredRange( aScalarRange ); + + return aScalarRange[ 1 ]; +} + + +//---------------------------------------------------------------------------- +CORBA::Boolean +VISU::ColoredPrs3d_i +::IsScalarFilterUsed() +{ + return myColoredPL->IsScalarFilterUsed(); +} + +//---------------------------------------------------------------------------- +void +VISU::ColoredPrs3d_i +::UseScalarFiltering( CORBA::Boolean theUseScalarFilter ) +{ + return myColoredPL->UseScalarFiltering( theUseScalarFilter ); +} + //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i @@ -804,9 +855,9 @@ VISU::ColoredPrs3d_i ProcessVoidEvent(new TVoidMemFunEvent (GetSpecificPL(), &VISU_ColoredPL::SetSourceRange)); }else{ - vtkFloatingPointType aScalarRange[2] = {GetSourceMin(), GetSourceMax()}; - ProcessVoidEvent(new TVoidMemFun2ArgEvent - (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange, false)); + vtkFloatingPointType aScalarRange[ 2 ] = {GetSourceMin(), GetSourceMax()}; + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange)); } UseFixedRange(false); } @@ -1506,14 +1557,15 @@ VISU::ColoredPrs3d_i // Scalar Range int aRangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0); - if(aRangeType == 1){ + if ( aRangeType == 1 ) { float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0); float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0); -// RKV SetRange(aMin, aMax); - bool isFiltered = aResourceMgr->booleanValue("VISU", "scalar_bar_filter_by_scalars", false); // RKV - SetRangeAndFilter(aMin, aMax, isFiltered); + SetRange( aMin, aMax ); } - UseFixedRange(aRangeType == 1); + UseFixedRange( aRangeType == 1 ); + + bool isFiltered = aResourceMgr->booleanValue("VISU", "scalar_bar_filter_by_scalars", false); + UseScalarFiltering( isFiltered ); int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 ); SetNbColors(aNumberOfColors); @@ -1676,15 +1728,20 @@ VISU::ColoredPrs3d_i Build(ERestore); - SetScalarMode(VISU::Storable::FindValue(theMap,"myScalarMode").toInt()); - float aMin = VISU::Storable::FindValue(theMap,"myScalarRange[0]").toDouble(); - float aMax = VISU::Storable::FindValue(theMap,"myScalarRange[1]").toDouble(); -// RKV SetRange(aMin, aMax); - // RKV : Begin - bool isFiltered = VISU::Storable::FindValue(theMap,"myIsFilteredByScalars", "0").toInt(); - SetRangeAndFilter(aMin, aMax, isFiltered); + SetScalarMode(VISU::Storable::FindValue( theMap,"myScalarMode" ).toInt() ); + { + float aMin = VISU::Storable::FindValue( theMap, "myScalarRange[0]" ).toDouble(); + float aMax = VISU::Storable::FindValue( theMap, "myScalarRange[1]" ).toDouble(); + SetRange( aMin, aMax ); + } + { + bool isFiltered = VISU::Storable::FindValue( theMap, "myIsFilteredByScalars", "0" ).toInt(); + float aMin = VISU::Storable::FindValue( theMap, "myScalarFilterRange[0]" ).toDouble(); + float aMax = VISU::Storable::FindValue( theMap, "myScalarFilterRange[1]" ).toDouble(); + SetScalarFilterRange( aMin, aMax ); + UseScalarFiltering( isFiltered ); + } SetIsDistributionVisible(VISU::Storable::FindValue(theMap,"myIsDistributionVisible", "0").toInt()); - // RKV : End UseFixedRange(VISU::Storable::FindValue(theMap,"myIsFixedRange", "0").toInt()); @@ -1755,7 +1812,10 @@ VISU::ColoredPrs3d_i Storable::DataToStream( theStr, "myScalarRange[1]", GetMax() ); Storable::DataToStream( theStr, "myIsFixedRange", IsRangeFixed() ); - Storable::DataToStream( theStr, "myIsFilteredByScalars", IsFilteredByScalars() ); // RKV + Storable::DataToStream( theStr, "myIsFilteredByScalars", IsScalarFilterUsed() ); + Storable::DataToStream( theStr, "myScalarFilterRange[0]", GetScalarFilterMin() ); + Storable::DataToStream( theStr, "myScalarFilterRange[1]", GetScalarFilterMax() ); + Storable::DataToStream( theStr, "myIsDistributionVisible", GetIsDistributionVisible() ); // RKV Storable::DataToStream( theStr, "myNumberOfColors", int(GetNbColors()) ); @@ -1914,7 +1974,6 @@ VISU::ColoredPrs3d_i return this; } -// RKV : Begin //---------------------------------------------------------------------------- void VISU::ColoredPrs3d_i @@ -1936,26 +1995,3 @@ VISU::ColoredPrs3d_i } //---------------------------------------------------------------------------- -CORBA::Boolean -VISU::ColoredPrs3d_i -::IsFilteredByScalars() -{ - return myColoredPL->IsFiltered(); -} - -//---------------------------------------------------------------------------- -void -VISU::ColoredPrs3d_i -::SetRangeAndFilter(CORBA::Double theMin, CORBA::Double theMax, CORBA::Boolean isFilter) -{ - VISU::TSetModified aModified(this); - - vtkFloatingPointType aScalarRange[2] = {theMin, theMax}; - ProcessVoidEvent(new TVoidMemFun2ArgEvent - (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange, isFilter)); - - UseFixedRange(true); -} - -//---------------------------------------------------------------------------- -// RKV : End diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 1215ac7b..52f5f631 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -355,7 +355,6 @@ namespace VISU CORBA::Boolean IsUnitsVisible(); -// RKV : Begin /*! * Set the visibility of a distribution curve. * \param theIs is used to switch on/off the visibility of a distribution curve. @@ -366,8 +365,10 @@ namespace VISU virtual CORBA::Boolean GetIsDistributionVisible(); //! Gets current filtering by scalars mode - virtual CORBA::Boolean IsFilteredByScalars(); + virtual CORBA::Boolean IsScalarFilterUsed(); + virtual void UseScalarFiltering( CORBA::Boolean theUseScalarFilter ); + /*! * Sets scalar range - min and max boundaries of the scalar bar. * \param theMin Min boundary of the scalar bar. @@ -376,8 +377,17 @@ namespace VISU */ virtual void - SetRangeAndFilter(CORBA::Double theMin, CORBA::Double theMax, CORBA::Boolean theIs); -// RKV : End + SetScalarFilterRange( CORBA::Double theMin, CORBA::Double theMax ); + + //---------------------------------------------------------------------------- + virtual + CORBA::Double + GetScalarFilterMin(); + + //---------------------------------------------------------------------------- + virtual + CORBA::Double + GetScalarFilterMax(); //---------------------------------------------------------------------------- //! Gets memory size actually used by the presentation (Mb). diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 87453dcb..42e007a0 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -1091,8 +1091,8 @@ VISU::GaussPoints_i VISU::TSetModified aModified(this); vtkFloatingPointType aScalarRange[2] = {GetSourceMin(), GetSourceMax()}; - ProcessVoidEvent(new TVoidMemFun2ArgEvent - (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange, false)); + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (GetSpecificPL(), &VISU_ColoredPL::SetScalarRange, aScalarRange)); UseFixedRange(false); }